Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(exit): delete heap-based QApplication before exit
Browse files Browse the repository at this point in the history
Fixes #4648
  • Loading branch information
anthonybilinski committed Sep 14, 2017
1 parent c499597 commit a601df3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ int main(int argc, char* argv[])

qInstallMessageHandler(logMessageHandler);

QApplication* a = new QApplication(argc, argv);
std::unique_ptr<QApplication> a(new QApplication(argc, argv));

#if defined(Q_OS_UNIX)
// PosixSignalNotifier is used only for terminating signals,
// so it's connected directly to quit() without any filtering.
QObject::connect(&PosixSignalNotifier::globalInstance(),
&PosixSignalNotifier::activated,
a,
a.get(),
&QApplication::quit);
PosixSignalNotifier::watchCommonTerminatingSignals();
#endif
Expand Down Expand Up @@ -326,14 +326,13 @@ int main(int argc, char* argv[])
else if (eventType == "save")
handleToxSave(firstParam.toUtf8());

QObject::connect(a, &QApplication::aboutToQuit, cleanup);
QObject::connect(a.get(), &QApplication::aboutToQuit, cleanup);

// Run (unless we already quit before starting!)
int errorcode = 0;
if (nexus.isRunning())
errorcode = a->exec();

qDebug() << "Exit with status" << errorcode;
delete a;
return errorcode;
}

0 comments on commit a601df3

Please sign in to comment.