mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
Make code windows specific
This commit is contained in:
parent
a66e1148ba
commit
76e39a3ebd
1 changed files with 17 additions and 7 deletions
|
@ -24,13 +24,27 @@
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QStandardPaths>
|
#include <QtCore/QStandardPaths>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
VOID CALLBACK parentDiedCallback(PVOID lpParameter, BOOLEAN timerOrWaitFired) {
|
VOID CALLBACK parentDiedCallback(PVOID lpParameter, BOOLEAN timerOrWaitFired) {
|
||||||
if (!timerOrWaitFired) {
|
if (!timerOrWaitFired && qApp) {
|
||||||
qDebug() << "Parent process died, quitting";
|
qDebug() << "Parent process died, quitting";
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void watchParentProcess(int parentPID) {
|
||||||
|
DWORD processID = parentPID;
|
||||||
|
HANDLE procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
|
||||||
|
|
||||||
|
HANDLE newHandle;
|
||||||
|
RegisterWaitForSingleObject(&newHandle, procHandle, parentDiedCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void watchParentProcess(int parentPID) {
|
||||||
|
qWarning() << "Parent PID option not implemented on this plateform";
|
||||||
|
}
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv)
|
QCoreApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
@ -212,16 +226,12 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD processID;
|
|
||||||
HANDLE procHandle;
|
|
||||||
HANDLE newHandle;
|
|
||||||
if (parser.isSet(parentPIDOption)) {
|
if (parser.isSet(parentPIDOption)) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
processID = parser.value(parentPIDOption).toInt(&ok);
|
int parentPID = parser.value(parentPIDOption).toInt(&ok);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
|
watchParentProcess(parentPID);
|
||||||
RegisterWaitForSingleObject(&newHandle, procHandle, parentDiedCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue