potential fix for issue #217 (SigSegV while in game room in KillAllTeams - team list change?)
authorsheepluva
Sun, 23 Oct 2011 09:01:53 +0200
changeset 6190 1db2486e45f4
parent 6189 d0d666503fd5
child 6191 190a8e5d9956
potential fix for issue #217 (SigSegV while in game room in KillAllTeams - team list change?)
QTfrontend/hwform.cpp
QTfrontend/hwform.h
--- a/QTfrontend/hwform.cpp	Sun Oct 23 01:47:44 2011 -0400
+++ b/QTfrontend/hwform.cpp	Sun Oct 23 09:01:53 2011 +0200
@@ -455,6 +455,10 @@
 
 void HWForm::OnPageShown(quint8 id, quint8 lastid)
 {
+    // with all those signals firing around make sure we don't switch a page
+    // at the same time in different threads
+    onPageShownMutex.lock();
+
 #ifdef USE_XFIRE
     updateXfire();
 #endif
@@ -479,6 +483,13 @@
             ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished();
     }
 
+    if (id == ID_PAGE_ROOMSLIST) {
+        if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
+            game->netSuspend = true;
+            game->KillAllTeams();
+        }
+    }
+
     if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) {
         QStringList tmNames = config->GetTeamsList();
         TeamSelWidget* curTeamSelWidget;
@@ -525,13 +536,11 @@
     if (id == ID_PAGE_NETGAME) // joining a room
         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
 // joining the lobby 
-    else if (id == ID_PAGE_ROOMSLIST) {
-        if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
-            game->netSuspend = true;
-            game->KillAllTeams();
-        }
+    else if (id == ID_PAGE_ROOMSLIST)
         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
-    }
+
+
+    onPageShownMutex.unlock();
 }
 
 void HWForm::GoToPage(int id)
--- a/QTfrontend/hwform.h	Sun Oct 23 01:47:44 2011 -0400
+++ b/QTfrontend/hwform.h	Sun Oct 23 09:01:53 2011 +0200
@@ -20,6 +20,7 @@
 #define HWFORM_H
 
 #include <QMainWindow>
+#include <QMutex>
 #include <QStack>
 #include <QTime>
 
@@ -168,12 +169,13 @@
     BGWidget * wBackground;
     QSignalMapper * pageSwitchMapper;
     QByteArray m_lastDemo;
+    QMutex onPageShownMutex;
 
 #ifdef __APPLE__
     InstallController * panel;
 #endif
 
-    void OnPageShown(quint8 id, quint8 lastid=0);
+    void OnPageShown(quint8 id, quint8 lastid=0); // thread-safe
 };
 
 #endif