MCPcopy Create free account
hub / github.com/KDE/kdevelop / handleLockedSession

Method handleLockedSession

kdevplatform/shell/sessionlock.cpp:135–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135QString SessionLock::handleLockedSession(const QString& sessionName, const QString& sessionId,
136 const SessionRunInfo& runInfo)
137{
138 if( !runInfo.isRunning ) {
139 return sessionId;
140 }
141
142 // try to make the locked session active
143 {
144 // The timeout for "ensureVisible" call
145 // Leave it sufficiently low to avoid waiting for hung instances.
146 static const int timeout_ms = 1000;
147
148 QDBusMessage message = QDBusMessage::createMethodCall( dBusServiceNameForSession(sessionId),
149 QStringLiteral("/kdevelop/MainWindow"),
150 QStringLiteral("org.kdevelop.MainWindow"),
151 QStringLiteral("ensureVisible") );
152 QDBusMessage reply = QDBusConnection::sessionBus().call( message,
153 QDBus::Block,
154 timeout_ms );
155 if( reply.type() == QDBusMessage::ReplyMessage ) {
156 QTextStream out(stdout);
157 out << i18nc(
158 "@info:shell",
159 "Running %1 instance (PID: %2) detected, making this one visible instead of starting a new one",
160 runInfo.holderApp, runInfo.holderPid)
161 << Qt::endl;
162 return QString();
163 } else {
164 qCWarning(SHELL) << i18nc("@info:shell", "Running %1 instance (PID: %2) is apparently hung", runInfo.holderApp, runInfo.holderPid);
165 }
166 }
167
168 // otherwise ask the user whether we should retry
169 QString problemDescription = i18nc("@info",
170 "The given application did not respond to a DBUS call, "
171 "it may have crashed or is hanging.");
172
173 QString problemHeader;
174 if( runInfo.holderPid != -1 ) {
175 problemHeader = i18nc("@info", "Failed to lock the session <em>%1</em>, "
176 "already locked by %2 on %3 (PID %4).",
177 sessionName, runInfo.holderApp, runInfo.holderHostname, runInfo.holderPid);
178 } else {
179 problemHeader = i18nc("@info", "Failed to lock the session <em>%1</em> (lock-file unavailable).",
180 sessionName);
181 }
182
183 QString problemResolution = i18nc("@info", "<p>Please, close the offending application instance "
184 "or choose another session to launch.</p>");
185
186 QString errmsg = QLatin1String("<p>") + problemHeader + QLatin1String("<br>") + problemDescription + QLatin1String("</p>") + problemResolution;
187
188 KGuiItem retry = KStandardGuiItem::cont();
189 retry.setText(i18nc("@action:button", "Retry Startup"));
190
191 KGuiItem choose = KStandardGuiItem::configure();
192 choose.setText(i18nc("@action:button", "Choose Another Session"));

Callers

nothing calls this directly

Calls 5

setupFlagsMethod · 0.80
QStringClass · 0.70
typeMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected