may be a bit better quit handling

This commit is contained in:
Blue 2022-01-25 23:35:55 +03:00
parent c708c33a92
commit 802e2f11a1
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
7 changed files with 46 additions and 12 deletions

View file

@ -105,11 +105,15 @@ int main(int argc, char *argv[])
QThread* coreThread = new QThread();
squawk->moveToThread(coreThread);
QObject::connect(&sc, &SignalCatcher::interrupt, &app, &QApplication::closeAllWindows);
QObject::connect(coreThread, &QThread::started, squawk, &Core::Squawk::start);
QObject::connect(&app, &QApplication::aboutToQuit, squawk, &Core::Squawk::stop);
QObject::connect(&app, &QApplication::aboutToQuit, &w, &QMainWindow::close);
QObject::connect(squawk, &Core::Squawk::quit, coreThread, &QThread::quit);
QObject::connect(coreThread, &QThread::finished, squawk, &Core::Squawk::deleteLater);
QObject::connect(&app, &QApplication::lastWindowClosed, squawk, &Core::Squawk::stop);
QObject::connect(&app, &QApplication::lastWindowClosed, &w, &Squawk::writeSettings);
//QObject::connect(&app, &QApplication::aboutToQuit, &w, &QMainWindow::close);
QObject::connect(squawk, &Core::Squawk::quit, squawk, &Core::Squawk::deleteLater);
QObject::connect(squawk, &Core::Squawk::quit, coreThread, &QThread::quit, Qt::QueuedConnection);
QObject::connect(coreThread, &QThread::finished, &app, &QApplication::quit, Qt::QueuedConnection);
QObject::connect(&w, &Squawk::newAccountRequest, squawk, &Core::Squawk::newAccountRequest);
QObject::connect(&w, &Squawk::modifyAccountRequest, squawk, &Core::Squawk::modifyAccountRequest);
@ -169,12 +173,11 @@ int main(int argc, char *argv[])
QObject::connect(squawk, &Core::Squawk::ready, &w, &Squawk::readSettings);
coreThread->start();
int result = app.exec();
w.writeSettings();
coreThread->wait(500); //TODO hate doing that but settings for some reason don't get saved to the disk
if (coreThread->isRunning()) {
coreThread->wait();
}
return result;
}

View file

@ -50,7 +50,7 @@ void SignalCatcher::handleSigInt()
char tmp;
ssize_t s = ::read(sigintFd[1], &tmp, sizeof(tmp));
app->quit();
emit interrupt();
snInt->setEnabled(true);
}

View file

@ -33,6 +33,9 @@ public:
static void intSignalHandler(int unused);
signals:
void interrupt();
public slots:
void handleSigInt();