File Info

Rev. efeab20e689880041b1ce76d479bb22c776d3f74
Size 2,205 bytes
Time 2020-07-04 19:41:12
Author simphone
Log Message

simphone 0.8.1

Content

diff -urb qt-solutions/qtsingleapplication/src/qtlocalpeer.cpp qtsingleapplication/qtlocalpeer.cpp
--- qt-solutions/qtsingleapplication/src/qtlocalpeer.cpp
+++ qtsingleapplication/qtlocalpeer.cpp
@@ -138,12 +138,12 @@
     if (!isClient())
         return false;
 
-    QLocalSocket socket;
+    QLocalSocket *socket = new QLocalSocket();
     bool connOk = false;
     for(int i = 0; i < 2; i++) {
         // Try twice, in case the other instance is just starting up
-        socket.connectToServer(socketName);
-        connOk = socket.waitForConnected(timeout/2);
+        socket->connectToServer(socketName);
+        connOk = socket->waitForConnected(timeout/2);
         if (connOk || i)
             break;
         int ms = 250;
@@ -158,14 +158,19 @@
         return false;
 
     QByteArray uMsg(message.toUtf8());
-    QDataStream ds(&socket);
+    QDataStream ds(socket);
     ds.writeBytes(uMsg.constData(), uMsg.size());
-    bool res = socket.waitForBytesWritten(timeout);
+    bool res = socket->waitForBytesWritten(timeout);
     if (res) {
-        res &= socket.waitForReadyRead(timeout);   // wait for ack
+        res &= socket->waitForReadyRead(timeout);   // wait for ack
         if (res)
-            res &= (socket.read(qstrlen(ack)) == ack);
+            res &= (socket->read(qstrlen(ack)) == ack);
+        delete socket;
     }
+#if !defined(Q_OS_WIN)
+    else
+        delete socket;
+#endif
     return res;
 }
 
diff -urb qt-solutions/qtsingleapplication/src/qtlocalpeer.h qtsingleapplication/qtlocalpeer.h
--- qt-solutions/qtsingleapplication/src/qtlocalpeer.h
+++ qtsingleapplication/qtlocalpeer.h
@@ -64,7 +64,7 @@
 protected Q_SLOTS:
     void receiveConnection();
 
-protected:
+public:
     QString id;
     QString socketName;
     QLocalServer* server;
diff -urb qt-solutions/qtsingleapplication/src/qtsingleapplication.h qtsingleapplication/qtsingleapplication.h
--- qt-solutions/qtsingleapplication/src/qtsingleapplication.h
+++ qtsingleapplication/qtsingleapplication.h
@@ -96,7 +96,7 @@
     void messageReceived(const QString &message);
 
 
-private:
+public:
     void sysInit(const QString &appId = QString());
     QtLocalPeer *peer;
     QWidget *actWin;
Show on old repository browser