Skip to content

Commit

Permalink
Never destroy QApplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
horacekj committed Jan 4, 2020
1 parent 76d6632 commit 204c222
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib-main.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ private slots:

// Dirty magic for Qt's event loop
// This class should be created first
class AppThread {
std::unique_ptr<QApplication> app;
int argc {0};

public:
struct AppThread {
AppThread() {
if (nullptr == QApplication::instance()) {
app = std::make_unique<QApplication>(argc, nullptr);
if (qApp == nullptr) {
int argc = 0;
QApplication* app = new QApplication(argc, nullptr);
QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
app->exec();
}
Expand Down

0 comments on commit 204c222

Please sign in to comment.