Okay, remove previous request only if it has same parent
authorunc0rr
Tue, 20 Nov 2012 00:10:12 +0400
changeset 8070 66bc20d089fc
parent 8069 bb7671829935
child 8071 7d6aaba59505
Okay, remove previous request only if it has same parent as this one. Fixes the last note of previous commit (which was nearly impossible to hit, but whatever, just cleaning implementation)
QTfrontend/game.cpp
QTfrontend/net/hwmap.cpp
QTfrontend/net/hwmap.h
QTfrontend/net/tcpBase.cpp
QTfrontend/net/tcpBase.h
QTfrontend/ui/widget/mapContainer.cpp
--- a/QTfrontend/game.cpp	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/game.cpp	Tue Nov 20 00:10:12 2012 +0400
@@ -37,7 +37,7 @@
 QString training, campaign, campaignScript, campaignTeam; // TODO: Cleaner solution?
 
 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
-    TCPBase(true),
+    TCPBase(true, 0),
     ammostr(ammo),
     m_pTeamSelWidget(pTeamSelWidget)
 {
--- a/QTfrontend/net/hwmap.cpp	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/net/hwmap.cpp	Tue Nov 20 00:10:12 2012 +0400
@@ -20,8 +20,8 @@
 #include "hwconsts.h"
 #include "hwmap.h"
 
-HWMap::HWMap() :
-    TCPBase(false)
+HWMap::HWMap(QObject * parent) :
+    TCPBase(false, parent)
 {
 }
 
--- a/QTfrontend/net/hwmap.h	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/net/hwmap.h	Tue Nov 20 00:10:12 2012 +0400
@@ -39,7 +39,7 @@
         Q_OBJECT
 
     public:
-        HWMap();
+        HWMap(QObject *parent = 0);
         virtual ~HWMap();
         void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData);
         bool couldBeRemoved();
--- a/QTfrontend/net/tcpBase.cpp	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/net/tcpBase.cpp	Tue Nov 20 00:10:12 2012 +0400
@@ -38,7 +38,8 @@
         IPCSocket->deleteLater();
 }
 
-TCPBase::TCPBase(bool demoMode) :
+TCPBase::TCPBase(bool demoMode, QObject *parent) :
+    QObject(parent),
     m_hasStarted(false),
     m_isDemoMode(demoMode),
     IPCSocket(0)
@@ -144,9 +145,12 @@
     }
     else
     {
-        if(couldCancelPreviousRequest && srvsList.last()->couldBeRemoved())
+        TCPBase * last = srvsList.last();
+        if(couldCancelPreviousRequest
+            && last->couldBeRemoved()
+            && (last->parent() == parent()))
         {
-            TCPBase * last = srvsList.takeLast();
+            srvsList.removeLast();
             last->deleteLater();
             Start(couldCancelPreviousRequest);
         } else
--- a/QTfrontend/net/tcpBase.h	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/net/tcpBase.h	Tue Nov 20 00:10:12 2012 +0400
@@ -38,7 +38,7 @@
         Q_OBJECT
 
     public:
-        TCPBase(bool demoMode);
+        TCPBase(bool demoMode, QObject * parent = 0);
         virtual ~TCPBase();
 
         virtual bool couldBeRemoved();
--- a/QTfrontend/ui/widget/mapContainer.cpp	Mon Nov 19 23:43:45 2012 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Tue Nov 20 00:10:12 2012 +0400
@@ -298,7 +298,7 @@
 
 void HWMapContainer::askForGeneratedPreview()
 {
-    pMap = new HWMap();
+    pMap = new HWMap(this);
     connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
     connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int)));
     connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *)));