gui: main: Kill IPCServer process on exit

This commit is contained in:
Albert S. 2022-05-27 10:51:02 +02:00
parent 0d6fb1d482
commit d66e395fda

View File

@ -73,7 +73,10 @@ int main(int argc, char *argv[])
QProcess process; QProcess process;
QStringList args; QStringList args;
args << "ipc"; args << "ipc";
if(!process.startDetached("/proc/self/exe", args)) process.setProcessChannelMode(QProcess::ForwardedChannels);
process.start("/proc/self/exe", args);
if(!process.waitForStarted(5000))
{ {
QString errorMsg = "Failed to start IPC server"; QString errorMsg = "Failed to start IPC server";
qDebug() << errorMsg; qDebug() << errorMsg;
@ -108,9 +111,9 @@ int main(int argc, char *argv[])
QMessageBox::critical(nullptr, "Error", e.message); QMessageBox::critical(nullptr, "Error", e.message);
return 1; return 1;
} }
// Keep this post sandbox, afterwards does not work (suspect due to threads, but unconfirmed)
QApplication a(argc, argv); QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/icon.svg")); a.setWindowIcon(QIcon(":/icon.svg"));
QObject::connect(&a, &QApplication::aboutToQuit, &process, &QProcess::kill);
qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>"); qRegisterMetaType<QVector<SearchResult>>("QVector<SearchResult>");
qRegisterMetaType<QVector<PreviewResultPdf>>("QVector<PreviewResultPdf>"); qRegisterMetaType<QVector<PreviewResultPdf>>("QVector<PreviewResultPdf>");