1 --- QtSingleApplication-2.6.1/src/qtlocalpeer.cpp~ 2015-02-22 21:20:10.000000000 +0200
2 +++ QtSingleApplication-2.6.1/src/qtlocalpeer.cpp 2015-02-22 21:21:00.011791211 +0200
4 #include "qtlocalpeer.h"
5 #include <QCoreApplication>
13 bool QtLocalPeer::sendMessage(const QString &message, int timeout)
15 + return sendMessage(message.toUtf8(), timeout);
18 +bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
27 - QByteArray uMsg(message.toUtf8());
28 QDataStream ds(&socket);
29 - ds.writeBytes(uMsg.constData(), uMsg.size());
30 + ds.writeBytes(message.constData(), message.size());
31 bool res = socket.waitForBytesWritten(timeout);
32 res &= socket.waitForReadyRead(timeout); // wait for ack
33 res &= (socket.read(qstrlen(ack)) == ack);
38 - QString message(QString::fromUtf8(uMsg));
39 socket->write(ack, qstrlen(ack));
40 socket->waitForBytesWritten(1000);
41 socket->waitForDisconnected(1000); // make sure client reads ack
43 - emit messageReceived(message); //### (might take a long time to return)
44 + emit messageReceived(uMsg); //### (might take a long time to return)
45 + emit messageReceived(QString::fromUtf8(uMsg));
47 --- qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h 2009-12-16 10:43:33.000000000 +0000
48 +++ qtsingleapplication/src/qtlocalpeer.h 2010-07-10 16:26:16.000000000 +0100
50 QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
52 bool sendMessage(const QString &message, int timeout);
53 + bool sendMessage(const QByteArray &message, int timeout);
54 QString applicationId() const
58 void messageReceived(const QString &message);
59 + void messageReceived(const QByteArray &message);
62 void receiveConnection();
63 --- qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp 2009-12-16 10:43:33.000000000 +0000
64 +++ qtsingleapplication/src/qtlockedfile_win.cpp 2010-07-10 16:26:33.000000000 +0100
69 - QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
70 + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
71 { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
73 qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
78 - QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
79 + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
80 { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
82 if (GetLastError() != ERROR_FILE_NOT_FOUND)
83 --- qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp 2009-12-16 10:43:33.000000000 +0000
84 +++ qtsingleapplication/src/qtsingleapplication.cpp 2010-07-10 16:23:53.000000000 +0100
87 peer = new QtLocalPeer(this, appId);
88 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
89 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
94 return peer->sendMessage(message, timeout);
97 +bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
99 + return peer->sendMessage(message, timeout);
104 Returns the application identifier. Two processes with the same
105 @@ -291,10 +297,14 @@
106 void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
109 - if (activateOnMessage)
110 + if (activateOnMessage) {
111 connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
113 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
116 disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
117 + disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
122 --- qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h 2009-12-16 10:43:33.000000000 +0000
123 +++ qtsingleapplication/src/qtsingleapplication.h 2010-07-10 16:23:53.000000000 +0100
127 bool sendMessage(const QString &message, int timeout = 5000);
128 + bool sendMessage(const QByteArray &message, int timeout = 5000);
129 void activateWindow();
133 void messageReceived(const QString &message);
134 + void messageReceived(const QByteArray &message);
138 --- qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp 2009-12-16 10:43:33.000000000 +0000
139 +++ qtsingleapplication/src/qtsinglecoreapplication.cpp 2010-07-10 16:32:33.000000000 +0100
142 peer = new QtLocalPeer(this);
143 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
144 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
150 peer = new QtLocalPeer(this, appId);
151 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
152 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
157 return peer->sendMessage(message, timeout);
160 +bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
162 + return peer->sendMessage(message, timeout);
167 Returns the application identifier. Two processes with the same
168 --- qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h 2009-12-16 10:43:33.000000000 +0000
169 +++ qtsingleapplication/src/qtsinglecoreapplication.h 2010-07-10 16:32:33.000000000 +0100
173 bool sendMessage(const QString &message, int timeout = 5000);
174 + bool sendMessage(const QByteArray &message, int timeout = 5000);
178 void messageReceived(const QString &message);
179 + void messageReceived(const QByteArray &message);