MCPcopy Create free account
hub / github.com/IJHack/QtPass / SingleApplication

Method SingleApplication

src/singleapplication.cpp:17–38  ·  view source on GitHub ↗

* @brief SingleApplication::SingleApplication this replaces the QApplication * allowing for local socket based communications. * @param argc * @param argv * @param uniqueKey */

Source from the content-addressed store, hash-verified

15 * @param uniqueKey
16 */
17SingleApplication::SingleApplication(int &argc, char *argv[], QString uniqueKey)
18 : QApplication(argc, argv), _uniqueKey(std::move(uniqueKey)) {
19 sharedMemory.setKey(_uniqueKey);
20 if (sharedMemory.attach()) {
21 _isRunning = true;
22 } else {
23 _isRunning = false;
24 // create shared memory.
25 if (!sharedMemory.create(1)) {
26#ifdef QT_DEBUG
27 dbg() << "Unable to create single instance.";
28#endif
29 return;
30 }
31 // create local server and listen to incomming messages from other
32 // instances.
33 localServer.reset(new QLocalServer(this));
34 connect(localServer.data(), &QLocalServer::newConnection, this,
35 &SingleApplication::receiveMessage);
36 localServer->listen(_uniqueKey);
37 }
38}
39
40// public slots.
41

Callers

nothing calls this directly

Calls 1

dataMethod · 0.80

Tested by

no test coverage detected