blob: f55b45e0709d1534f80546b3b78d63dbbbc4908e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (C) 2017 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "timemodel.h"
#include <QCoreApplication>
/*
* http://stackoverflow.com/questions/7404163/windows-handling-ctrlc-in-different-thread
*/
void SigIntHandler()
{
qDebug()<<"Ctrl-C received. Quitting.";
qApp->quit();
}
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_QNX)
#include <signal.h>
void unix_handler(int s)
{
if (s==SIGINT)
SigIntHandler();
}
#elif defined(Q_OS_WIN32)
#include <windows.h>
BOOL WINAPI WinHandler(DWORD CEvent)
{
switch (CEvent)
{
case CTRL_C_EVENT:
SigIntHandler();
break;
}
return TRUE;
}
#endif
//![0]
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_QNX)
signal(SIGINT, &unix_handler);
#elif defined(Q_OS_WIN32)
SetConsoleCtrlHandler((PHANDLER_ROUTINE)WinHandler, TRUE);
#endif
QRemoteObjectHost node(QUrl(QStringLiteral("local:replica")),QUrl(QStringLiteral("local:registry")));
QRemoteObjectRegistryHost node2(QUrl(QStringLiteral("local:registry")));
MinuteTimer timer;
node2.enableRemoting(&timer);
Q_UNUSED(timer)
return app.exec();
}
//![0]
|