Cleanup: Implicitly free QApplication

Instead of deleting the Application explicitly in exit_ui(),
use a unique_ptr to have the instance automatically freed.
This is the pattern given in the Qt-docs:
https://doc.qt.io/qt-5/qapplication.html

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-09-29 13:21:12 +02:00 committed by Dirk Hohndel
parent 1e1f33c0f5
commit 7343fe4cc6
3 changed files with 2 additions and 4 deletions

View file

@ -43,7 +43,7 @@ int main(int argc, char **argv)
int i; int i;
bool no_filenames = true; bool no_filenames = true;
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
new QApplication(argc, argv); std::unique_ptr<QApplication> app(new QApplication(argc, argv));
QStringList files; QStringList files;
QStringList importedFiles; QStringList importedFiles;
QStringList arguments = QCoreApplication::arguments(); QStringList arguments = QCoreApplication::arguments();

View file

@ -56,7 +56,6 @@ void exit_ui()
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
delete MainWindow::instance(); delete MainWindow::instance();
#endif // SUBSURFACE_MOBILE #endif // SUBSURFACE_MOBILE
delete qApp;
free((void *)existing_filename); free((void *)existing_filename);
} }

View file

@ -53,7 +53,6 @@ void log_stp(const char *ident, QString *buf)
} }
#endif // ENABLE_STARTUP_TIMING #endif // ENABLE_STARTUP_TIMING
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
LOG_STP("main starting"); LOG_STP("main starting");
@ -63,7 +62,7 @@ int main(int argc, char **argv)
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true")); QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
// Start application // Start application
new QApplication(argc, argv); std::unique_ptr<QApplication> app(new QApplication(argc, argv));
LOG_STP("main Qt started"); LOG_STP("main Qt started");
// and get comand line arguments // and get comand line arguments