new more working, but still not completely working version :)
authordisplacer
Tue, 26 Sep 2006 19:45:47 +0000
changeset 169 a78d4a552500
parent 168 679e9b8912f5
child 170 ef1031ba44fc
new more working, but still not completely working version :)
QTfrontend/hwmap.cpp
QTfrontend/mapContainer.cpp
QTfrontend/mapContainer.h
--- a/QTfrontend/hwmap.cpp	Tue Sep 26 17:50:14 2006 +0000
+++ b/QTfrontend/hwmap.cpp	Tue Sep 26 19:45:47 2006 +0000
@@ -5,7 +5,6 @@
 #include <QMessageBox>
 
 #include <QMutex>
-#include <QDebug>
 
 #include <QList>
 
@@ -16,6 +15,9 @@
 HWMap::HWMap() :
   m_isStarted(false)
 {
+  IPCServer = new QTcpServer(this);
+  connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
+  IPCServer->setMaxPendingConnections(1);
 }
 
 HWMap::~HWMap()
@@ -34,17 +36,15 @@
   im.setNumColors(2);
 
   IPCSocket->close();
-  IPCSocket->deleteLater();
-  IPCSocket = 0;
+  //IPCSocket->deleteLater();
+  //IPCSocket = 0;
   IPCServer->close();
   //deleteLater();
 
 
   tcpSrvMut.lock();
   if(isBusy) --isBusy;
-  //if(!isBusy) srvsList.pop_front();//lastStarted=0;
   tcpSrvMut.unlock();
-  qDebug() << "image emitted with seed " << QString(m_seed.c_str());
   emit ImageReceived(im);
   readbuffer.clear();
   emit isReadyNow();
@@ -89,8 +89,6 @@
 
 void HWMap::tcpServerReady()
 {
-  qDebug() << "received signal, i am " << this << ";";
-  qDebug() << srvsList.front() << " disconnected from " << *(++srvsList.begin());
   tcpSrvMut.lock();
   disconnect(srvsList.front(), SIGNAL(isReadyNow()), *(++srvsList.begin()), SLOT(tcpServerReady()));
   srvsList.pop_front();
@@ -103,12 +101,10 @@
 {
   tcpSrvMut.lock();
   if(!isBusy) {
-    qDebug() << "notBusy, i am " << this;
     ++isBusy;
     srvsList.push_back(this);
     tcpSrvMut.unlock();
   } else {
-    qDebug() << "Busy, connected " << srvsList.back() << " to " << this;
     connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
     srvsList.push_back(this);
     //deleteLater();
@@ -121,9 +117,6 @@
 
 void HWMap::RealStart()
 {
-  IPCServer = new QTcpServer(this);
-  connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
-  IPCServer->setMaxPendingConnections(1);
   IPCSocket = 0;
   if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) {
     QMessageBox::critical(0, tr("Error"),
--- a/QTfrontend/mapContainer.cpp	Tue Sep 26 17:50:14 2006 +0000
+++ b/QTfrontend/mapContainer.cpp	Tue Sep 26 19:45:47 2006 +0000
@@ -37,8 +37,6 @@
 #include <QBuffer>
 #include <QUuid>
 
-#include <QDebug>
-
 HWMapContainer::HWMapContainer(QWidget * parent) :
   QWidget(parent), mainLayout(this)
 {
@@ -46,13 +44,11 @@
   imageButt->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
   mainLayout.addWidget(imageButt);
   connect(imageButt, SIGNAL(clicked()), this, SLOT(changeImage()));
-  connect(&m_hwmap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   changeImage();
 }
 
 void HWMapContainer::setImage(const QImage newImage)
 {
-  qDebug() << "image received";
   // unfortunately QPixmap::fromImage doesn't work 
   // with this image in current (4.1.4) version of QT
   QByteArray ba;
@@ -68,9 +64,10 @@
 
 void HWMapContainer::changeImage()
 {
+  pMap=new HWMap();
+  connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   m_seed = QUuid::createUuid().toString();
-  //pMap=new HWMap();
-  m_hwmap.getImage(m_seed.toStdString());
+  pMap->getImage(m_seed.toStdString());
 }
 
 QString HWMapContainer::getCurrentSeed() const
--- a/QTfrontend/mapContainer.h	Tue Sep 26 17:50:14 2006 +0000
+++ b/QTfrontend/mapContainer.h	Tue Sep 26 19:45:47 2006 +0000
@@ -61,7 +61,7 @@
  private:
   QVBoxLayout mainLayout;
   QPushButton* imageButt;
-  HWMap m_hwmap;
+  HWMap* pMap;
   QString m_seed;
 };