1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(main): Use application pointer

This commit is contained in:
Diadlo 2017-06-18 14:44:20 +03:00
parent 70428771fd
commit 9908c7473b
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -130,10 +130,10 @@ int main(int argc, char* argv[])
qInstallMessageHandler(logMessageHandler); qInstallMessageHandler(logMessageHandler);
QApplication a(argc, argv); QApplication* a = new QApplication(argc, argv);
a.setApplicationName("qTox"); a->setApplicationName("qTox");
a.setOrganizationName("Tox"); a->setOrganizationName("Tox");
a.setApplicationVersion("\nGit commit: " + QString(GIT_VERSION)); a->setApplicationVersion("\nGit commit: " + QString(GIT_VERSION));
// Install Unicode 6.1 supporting font // Install Unicode 6.1 supporting font
// Keep this as close to the beginning of `main()` as possible, otherwise // Keep this as close to the beginning of `main()` as possible, otherwise
@ -164,7 +164,7 @@ int main(int argc, char* argv[])
parser.addOption( parser.addOption(
QCommandLineOption("p", QObject::tr("Starts new instance and loads specified profile."), QCommandLineOption("p", QObject::tr("Starts new instance and loads specified profile."),
QObject::tr("profile"))); QObject::tr("profile")));
parser.process(a); parser.process(*a);
uint32_t profileId = Settings::getInstance().getCurrentProfileId(); uint32_t profileId = Settings::getInstance().getCurrentProfileId();
IPC ipc(profileId); IPC ipc(profileId);
@ -215,7 +215,7 @@ int main(int argc, char* argv[])
// Windows platform plugins DLL hell fix // Windows platform plugins DLL hell fix
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
a.addLibraryPath("platforms"); a->addLibraryPath("platforms");
qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")"; qDebug() << "built on: " << __TIME__ << __DATE__ << "(" << TIMESTAMP << ")";
qDebug() << "commit: " << GIT_VERSION << "\n"; qDebug() << "commit: " << GIT_VERSION << "\n";
@ -297,10 +297,11 @@ int main(int argc, char* argv[])
else if (eventType == "save") else if (eventType == "save")
handleToxSave(firstParam.toUtf8()); handleToxSave(firstParam.toUtf8());
// Run (unless we already quit before starting!) // Run (unless we already quit before starting!)
int errorcode = 0; int errorcode = 0;
if (nexus.isRunning()) if (nexus.isRunning())
errorcode = a.exec(); errorcode = a->exec();
Nexus::destroyInstance(); Nexus::destroyInstance();
CameraSource::destroyInstance(); CameraSource::destroyInstance();
@ -311,5 +312,7 @@ int main(int argc, char* argv[])
logFileFile.store(nullptr); // atomically disable logging to file logFileFile.store(nullptr); // atomically disable logging to file
fclose(mainLogFilePtr); fclose(mainLogFilePtr);
#endif #endif
delete a;
return errorcode; return errorcode;
} }