History

Move wm_close handling to a shared library

Ryan Huffman committed 12 years ago

Commit c27bee21 parent 444a9746 files · +69 −19Browse files

Showing the changes to assignment-client/src/AssignmentClient.cpp (1 of 6 files). Show all

Unified · Split

assignment-client/src/AssignmentClient.cpp+4−16
@@ -36,7 +36,8 @@ int hifiSockAddrMeta = qRegisterMetaType<HifiSockAddr>("HifiSockAddr"); · 35 unmodified lines
3636
3737 AssignmentClient::AssignmentClient(int &argc, char **argv) :
3838 QCoreApplication(argc, argv),
39− _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME)
39+ _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME),
40+ _shutdownEventListener(this)
4041 {
4142
4243 #ifdef Q_OS_WIN
@@ -54,7 +55,8 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) : · 11 unmodified lines
5455 setApplicationName("assignment-client");
5556 QSettings::setDefaultFormat(QSettings::IniFormat);
5657
57− installNativeEventFilter(this);
58+ installNativeEventFilter(&_shutdownEventListener);
59+ connect(&_shutdownEventListener, SIGNAL(receivedCloseEvent()), SLOT(quit()));
5860
5961 // set the logging target to the the CHILD_TARGET_NAME
6062 Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
@@ -121,20 +123,6 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) : · 60 unmodified lines
121123 NetworkAccessManager::getInstance();
122124 }
123125
124−bool AssignmentClient::nativeEventFilter(const QByteArray &eventType, void* msg, long* result) {
125−#ifdef Q_OS_WIN
126− if (eventType == "windows_generic_MSG") {
127− MSG* message = (MSG*)msg;
128− if (message->message == WM_CLOSE) {
129− qDebug() << "Received WM_CLOSE message, closing";
130− quit();
131− return false;
132− }
133− }
134−#endif
135− return true;
136−}
137−
138126 void AssignmentClient::sendAssignmentRequest() {
139127 if (!_currentAssignment) {
140128 NodeList::getInstance()->sendAssignment(_requestAssignment);