MCPcopy Create free account
hub / github.com/TeXworks/texworks / InterProcessCommunicator

Method InterProcessCommunicator

src/InterProcessCommunicatorDBus.cpp:60–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58};
59
60InterProcessCommunicator::InterProcessCommunicator()
61 : _private(new InterProcessCommunicatorPrivate(this))
62{
63 Q_D(InterProcessCommunicator);
64
65 d->serviceRegistered = QDBusConnection::sessionBus().registerService(QStringLiteral(TW_SERVICE_NAME));
66 if (d->serviceRegistered) {
67 _isFirstInstance = true;
68 }
69 else {
70 d->interface = new QDBusInterface(QString::fromLatin1(TW_SERVICE_NAME), QString::fromLatin1(TW_APP_PATH), QString::fromLatin1(TW_INTERFACE_NAME));
71 if (d->interface->isValid())
72 _isFirstInstance = false;
73 else {
74 // We could not register the service, but couldn't connect to an
75 // already registered one, either. This can mean that something is
76 // seriously wrong, we've met some race condition, or the dbus
77 // service is not running. Let's assume the best (dbus not running)
78 // and continue as a multiple-instance app instead
79 _isFirstInstance = true;
80 return;
81 }
82 }
83 if (_isFirstInstance) {
84 d->objectRegistered = QDBusConnection::sessionBus().registerObject(QStringLiteral(TW_APP_PATH), this);
85
86 // failed to register the application object, so unregister our service
87 // and continue as a multiple-instance app instead
88 if (!d->objectRegistered) {
89 QDBusConnection::sessionBus().unregisterService(QStringLiteral(TW_SERVICE_NAME));
90 d->serviceRegistered = false;
91 _isFirstInstance = false;
92 }
93 }
94}
95
96InterProcessCommunicator::~InterProcessCommunicator()
97{

Callers

nothing calls this directly

Calls 1

isValidMethod · 0.45

Tested by

no test coverage detected