Ticket #3606: networkcontrol-3606.diff.txt

File networkcontrol-3606.diff.txt, 1.6 KB (added by Russell Bryant <russell@…>, 17 years ago)
Line 
1Index: programs/mythfrontend/networkcontrol.cpp
2===================================================================
3--- programs/mythfrontend/networkcontrol.cpp    (revision 13665)
4+++ programs/mythfrontend/networkcontrol.cpp    (working copy)
5@@ -179,6 +179,7 @@
6     keyMap["f23"]                    = Qt::Key_F23;
7     keyMap["f24"]                    = Qt::Key_F24;
8 
9+    stopCommandThread = false;
10     pthread_create(&command_thread, NULL, CommandThread, this);
11 
12     gContext->addListener(this);
13@@ -193,7 +194,10 @@
14 
15     notifyDataAvailable();
16 
17-    pthread_cancel(command_thread);
18+    stopCommandThread = true;
19+    ncLock.lock();
20+    ncCond.wakeOne();
21+    ncLock.unlock();
22     pthread_join(command_thread, NULL);
23 }
24 
25@@ -209,14 +213,16 @@
26 {
27     QString command;
28 
29-    for (;;)
30+    while (!stopCommandThread)
31     {
32-        pthread_testcancel();
33-
34         ncLock.lock();
35         while (!networkControlCommands.size()) {
36             ncCond.wait(&ncLock);
37-            pthread_testcancel();
38+            if (stopCommandThread)
39+            {
40+                ncLock.unlock();
41+                return;
42+            }
43         }
44         command = networkControlCommands.front();
45         networkControlCommands.pop_front();
46Index: programs/mythfrontend/networkcontrol.h
47===================================================================
48--- programs/mythfrontend/networkcontrol.h      (revision 13665)
49+++ programs/mythfrontend/networkcontrol.h      (working copy)
50@@ -69,6 +69,7 @@
51     QMutex nrLock;
52 
53     pthread_t command_thread;
54+    bool stopCommandThread;
55 };
56 
57 #endif