mirror of https://github.com/procxx/kepka.git
Version 0.10.18: a couple of crash fixes.
This commit is contained in:
parent
53e48beb03
commit
1cfe9d0ff5
|
@ -345,6 +345,10 @@ _creationRequestId(0), _createdChannel(0) {
|
||||||
connect(&_next, SIGNAL(clicked()), this, SLOT(onNext()));
|
connect(&_next, SIGNAL(clicked()), this, SLOT(onNext()));
|
||||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||||
|
|
||||||
|
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
|
||||||
|
notifyFileQueryUpdated(update);
|
||||||
|
});
|
||||||
|
|
||||||
prepare();
|
prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,24 +549,23 @@ void GroupInfoBox::updateMaxHeight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupInfoBox::onPhoto() {
|
void GroupInfoBox::onPhoto() {
|
||||||
QStringList imgExtensions(cImgExtensions());
|
auto imgExtensions = cImgExtensions();
|
||||||
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter());
|
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
|
||||||
|
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_images), filter);
|
||||||
|
}
|
||||||
|
|
||||||
QImage img;
|
void GroupInfoBox::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update) {
|
||||||
QString file;
|
if (_setPhotoFileQueryId != update.queryId) {
|
||||||
QByteArray remoteContent;
|
|
||||||
if (filedialogGetOpenFile(file, remoteContent, lang(lng_choose_images), filter)) {
|
|
||||||
if (!remoteContent.isEmpty()) {
|
|
||||||
img = App::readImage(remoteContent);
|
|
||||||
} else {
|
|
||||||
if (!file.isEmpty()) {
|
|
||||||
img = App::readImage(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_setPhotoFileQueryId = 0;
|
||||||
|
|
||||||
|
QImage img;
|
||||||
|
if (!update.remoteContent.isEmpty()) {
|
||||||
|
img = App::readImage(update.remoteContent);
|
||||||
|
} else {
|
||||||
|
img = App::readImage(update.filePaths.front());
|
||||||
|
}
|
||||||
if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
|
if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "abstractbox.h"
|
#include "abstractbox.h"
|
||||||
#include "core/lambda_wrap.h"
|
#include "core/lambda_wrap.h"
|
||||||
|
#include "ui/filedialog.h"
|
||||||
|
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
class ConfirmBox;
|
class ConfirmBox;
|
||||||
|
@ -117,6 +118,8 @@ protected:
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update);
|
||||||
|
|
||||||
void step_photoOver(float64 ms, bool timer);
|
void step_photoOver(float64 ms, bool timer);
|
||||||
|
|
||||||
QRect photoRect() const;
|
QRect photoRect() const;
|
||||||
|
@ -140,6 +143,8 @@ private:
|
||||||
int32 _creationRequestId;
|
int32 _creationRequestId;
|
||||||
ChannelData *_createdChannel;
|
ChannelData *_createdChannel;
|
||||||
|
|
||||||
|
FileDialog::QueryId _setPhotoFileQueryId = 0;
|
||||||
|
|
||||||
void creationDone(const MTPUpdates &updates);
|
void creationDone(const MTPUpdates &updates);
|
||||||
bool creationFail(const RPCError &e);
|
bool creationFail(const RPCError &e);
|
||||||
void exportDone(const MTPExportedChatInvite &result);
|
void exportDone(const MTPExportedChatInvite &result);
|
||||||
|
|
|
@ -543,7 +543,7 @@ void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
||||||
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) return;
|
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) return;
|
||||||
if (!_mediaPreview) {
|
if (!_mediaPreview) {
|
||||||
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
||||||
resizeEvent(nullptr);
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
if (_mediaPreview->isHidden()) {
|
if (_mediaPreview->isHidden()) {
|
||||||
fixOrder();
|
fixOrder();
|
||||||
|
@ -555,7 +555,7 @@ void MainWindow::ui_showMediaPreview(PhotoData *photo) {
|
||||||
if (!photo) return;
|
if (!photo) return;
|
||||||
if (!_mediaPreview) {
|
if (!_mediaPreview) {
|
||||||
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
_mediaPreview = std_::make_unique<MediaPreviewWidget>(this);
|
||||||
resizeEvent(nullptr);
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
if (_mediaPreview->isHidden()) {
|
if (_mediaPreview->isHidden()) {
|
||||||
fixOrder();
|
fixOrder();
|
||||||
|
@ -583,7 +583,7 @@ void MainWindow::showConnecting(const QString &text, const QString &reconnect) {
|
||||||
} else {
|
} else {
|
||||||
_connecting.create(this, text, reconnect);
|
_connecting.create(this, text, reconnect);
|
||||||
_connecting->show();
|
_connecting->show();
|
||||||
resizeEvent(0);
|
updateControlsGeometry();
|
||||||
fixOrder();
|
fixOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1036,11 +1036,15 @@ void MainWindow::resizeEvent(QResizeEvent *e) {
|
||||||
Global::SetAdaptiveLayout(layout);
|
Global::SetAdaptiveLayout(layout);
|
||||||
Adaptive::Changed().notify(true);
|
Adaptive::Changed().notify(true);
|
||||||
}
|
}
|
||||||
|
updateControlsGeometry();
|
||||||
|
emit resized(QSize(width(), height() - st::titleHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateControlsGeometry() {
|
||||||
title->setGeometry(0, 0, width(), st::titleHeight);
|
title->setGeometry(0, 0, width(), st::titleHeight);
|
||||||
if (layerBg) layerBg->resize(width(), height());
|
if (layerBg) layerBg->resize(width(), height());
|
||||||
if (_mediaPreview) _mediaPreview->setGeometry(0, title->height(), width(), height() - title->height());
|
if (_mediaPreview) _mediaPreview->setGeometry(0, title->height(), width(), height() - title->height());
|
||||||
if (_connecting) _connecting->setGeometry(0, height() - _connecting->height(), _connecting->width(), _connecting->height());
|
if (_connecting) _connecting->setGeometry(0, height() - _connecting->height(), _connecting->width(), _connecting->height());
|
||||||
emit resized(QSize(width(), height() - st::titleHeight));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::TempDirState MainWindow::tempDirState() {
|
MainWindow::TempDirState MainWindow::tempDirState() {
|
||||||
|
|
|
@ -228,6 +228,8 @@ private:
|
||||||
void showConnecting(const QString &text, const QString &reconnect = QString());
|
void showConnecting(const QString &text, const QString &reconnect = QString());
|
||||||
void hideConnecting();
|
void hideConnecting();
|
||||||
|
|
||||||
|
void updateControlsGeometry();
|
||||||
|
|
||||||
QPixmap grabInner();
|
QPixmap grabInner();
|
||||||
|
|
||||||
void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color);
|
void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color);
|
||||||
|
|
|
@ -304,7 +304,7 @@ Thread::~Thread() {
|
||||||
Connection::Connection() : thread(nullptr), data(nullptr) {
|
Connection::Connection() : thread(nullptr), data(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Connection::start(SessionData *sessionData, int32 dc) {
|
int32 Connection::prepare(SessionData *sessionData, int32 dc) {
|
||||||
t_assert(thread == nullptr && data == nullptr);
|
t_assert(thread == nullptr && data == nullptr);
|
||||||
|
|
||||||
thread = new Thread();
|
thread = new Thread();
|
||||||
|
@ -318,11 +318,13 @@ int32 Connection::start(SessionData *sessionData, int32 dc) {
|
||||||
thread = nullptr;
|
thread = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->start();
|
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Connection::start() {
|
||||||
|
thread->start();
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::kill() {
|
void Connection::kill() {
|
||||||
t_assert(data != nullptr && thread != nullptr);
|
t_assert(data != nullptr && thread != nullptr);
|
||||||
data->stop();
|
data->stop();
|
||||||
|
|
|
@ -53,7 +53,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection();
|
Connection();
|
||||||
int32 start(SessionData *data, int32 dc = 0); // return dc
|
|
||||||
|
int32 prepare(SessionData *data, int32 dc = 0); // return dc
|
||||||
|
void start();
|
||||||
|
|
||||||
void kill();
|
void kill();
|
||||||
void waitTillFinish();
|
void waitTillFinish();
|
||||||
~Connection();
|
~Connection();
|
||||||
|
|
|
@ -70,7 +70,7 @@ void SessionData::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Session::Session(int32 dcenter) : QObject()
|
Session::Session(int32 requestedDcId) : QObject()
|
||||||
, _connection(0)
|
, _connection(0)
|
||||||
, _killed(false)
|
, _killed(false)
|
||||||
, _needToReceive(false)
|
, _needToReceive(false)
|
||||||
|
@ -96,19 +96,25 @@ Session::Session(int32 dcenter) : QObject()
|
||||||
|
|
||||||
connect(&sender, SIGNAL(timeout()), this, SLOT(needToResumeAndSend()));
|
connect(&sender, SIGNAL(timeout()), this, SLOT(needToResumeAndSend()));
|
||||||
|
|
||||||
DcenterMap &dcs(DCMap());
|
|
||||||
|
|
||||||
_connection = new Connection();
|
_connection = new Connection();
|
||||||
dcWithShift = _connection->start(&data, dcenter);
|
dcWithShift = _connection->prepare(&data, requestedDcId);
|
||||||
if (!dcWithShift) {
|
if (!dcWithShift) {
|
||||||
delete _connection;
|
delete _connection;
|
||||||
_connection = 0;
|
_connection = 0;
|
||||||
DEBUG_LOG(("Session Info: could not start connection to dc %1").arg(dcenter));
|
DEBUG_LOG(("Session Info: could not start connection to dc %1").arg(requestedDcId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createDcData();
|
||||||
|
_connection->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::createDcData() {
|
||||||
|
if (dc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!dc) {
|
|
||||||
dcenter = dcWithShift;
|
|
||||||
int32 dcId = bareDcId(dcWithShift);
|
int32 dcId = bareDcId(dcWithShift);
|
||||||
|
|
||||||
|
auto &dcs = DCMap();
|
||||||
auto dcIndex = dcs.constFind(dcId);
|
auto dcIndex = dcs.constFind(dcId);
|
||||||
if (dcIndex == dcs.cend()) {
|
if (dcIndex == dcs.cend()) {
|
||||||
dc = DcenterPtr(new Dcenter(dcId, AuthKeyPtr()));
|
dc = DcenterPtr(new Dcenter(dcId, AuthKeyPtr()));
|
||||||
|
@ -125,7 +131,6 @@ Session::Session(int32 dcenter) : QObject()
|
||||||
connect(dc.data(), SIGNAL(authKeyCreated()), this, SLOT(authKeyCreatedForDC()), Qt::QueuedConnection);
|
connect(dc.data(), SIGNAL(authKeyCreated()), this, SLOT(authKeyCreatedForDC()), Qt::QueuedConnection);
|
||||||
connect(dc.data(), SIGNAL(layerWasInited(bool)), this, SLOT(layerWasInitedForDC(bool)), Qt::QueuedConnection);
|
connect(dc.data(), SIGNAL(layerWasInited(bool)), this, SLOT(layerWasInitedForDC(bool)), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Session::restart() {
|
void Session::restart() {
|
||||||
if (_killed) {
|
if (_killed) {
|
||||||
|
@ -200,13 +205,15 @@ void Session::needToResumeAndSend() {
|
||||||
DcenterMap &dcs(DCMap());
|
DcenterMap &dcs(DCMap());
|
||||||
|
|
||||||
_connection = new Connection();
|
_connection = new Connection();
|
||||||
if (!_connection->start(&data, dcWithShift)) {
|
if (!_connection->prepare(&data, dcWithShift)) {
|
||||||
delete _connection;
|
delete _connection;
|
||||||
_connection = 0;
|
_connection = 0;
|
||||||
DEBUG_LOG(("Session Info: could not start connection to dcWithShift %1").arg(dcWithShift));
|
DEBUG_LOG(("Session Info: could not start connection to dcWithShift %1").arg(dcWithShift));
|
||||||
dcWithShift = 0;
|
dcWithShift = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
createDcData();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
if (_ping) {
|
if (_ping) {
|
||||||
_ping = false;
|
_ping = false;
|
||||||
|
|
|
@ -281,6 +281,8 @@ public slots:
|
||||||
void sendMsgsStateInfo(quint64 msgId, QByteArray data);
|
void sendMsgsStateInfo(quint64 msgId, QByteArray data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void createDcData();
|
||||||
|
|
||||||
Connection *_connection;
|
Connection *_connection;
|
||||||
|
|
||||||
bool _killed;
|
bool _killed;
|
||||||
|
|
Loading…
Reference in New Issue