Create Application before ConcurrentTimerEnvironment.

Fixes #5498.
This commit is contained in:
John Preston 2018-12-26 13:02:43 +04:00
parent 7b5e5c2587
commit cfac261516
3 changed files with 15 additions and 8 deletions

View File

@ -103,10 +103,13 @@ Application::Application(
char **argv) char **argv)
: QApplication(argc, argv) : QApplication(argc, argv)
, _mainThreadId(QThread::currentThreadId()) , _mainThreadId(QThread::currentThreadId())
, _launcher(launcher) , _launcher(launcher) {
, _updateChecker(Core::UpdaterDisabled() }
? nullptr
: std::make_unique<Core::UpdateChecker>()) { int Application::execute() {
if (!Core::UpdaterDisabled()) {
_updateChecker = std::make_unique<Core::UpdateChecker>();
}
const auto d = QFile::encodeName(QDir(cWorkingDir()).absolutePath()); const auto d = QFile::encodeName(QDir(cWorkingDir()).absolutePath());
char h[33] = { 0 }; char h[33] = { 0 };
hashMd5Hex(d.constData(), d.size(), h); hashMd5Hex(d.constData(), d.size(), h);
@ -134,6 +137,8 @@ Application::Application(
LOG(("Connecting local socket to %1...").arg(_localServerName)); LOG(("Connecting local socket to %1...").arg(_localServerName));
_localSocket.connectToServer(_localServerName); _localSocket.connectToServer(_localServerName);
} }
return exec();
} }
Application::~Application() = default; Application::~Application() = default;

View File

@ -21,7 +21,7 @@ class Application : public QApplication, private QAbstractNativeEventFilter {
public: public:
Application(not_null<Core::Launcher*> launcher, int &argc, char **argv); Application(not_null<Core::Launcher*> launcher, int &argc, char **argv);
bool event(QEvent *e) override; int execute();
void createMessenger(); void createMessenger();
void refreshGlobalProxy(); void refreshGlobalProxy();
@ -49,6 +49,9 @@ public slots:
void startApplication(); // will be done in exec() void startApplication(); // will be done in exec()
void closeApplication(); // will be done in aboutToQuit() void closeApplication(); // will be done in aboutToQuit()
protected:
bool event(QEvent *e) override;
private: private:
typedef QPair<QLocalSocket*, QByteArray> LocalClient; typedef QPair<QLocalSocket*, QByteArray> LocalClient;
typedef QList<LocalClient> LocalClients; typedef QList<LocalClient> LocalClients;

View File

@ -243,11 +243,10 @@ void Launcher::processArguments() {
} }
int Launcher::executeApplication() { int Launcher::executeApplication() {
Application application(this, _argc, _argv);
MainQueueProcessor processor; MainQueueProcessor processor;
base::ConcurrentTimerEnvironment environment; base::ConcurrentTimerEnvironment environment;
return application.execute();
Application app(this, _argc, _argv);
return app.exec();
} }
} // namespace Core } // namespace Core