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

Function getRunningSessionPid

app/main.cpp:259–281  ·  view source on GitHub ↗

Gets the PID of a running KDevelop instance, eventually asking the user if there is more than one. Returns -1 in case there are no running sessions.

Source from the content-addressed store, hash-verified

257/// Gets the PID of a running KDevelop instance, eventually asking the user if there is more than one.
258/// Returns -1 in case there are no running sessions.
259static qint64 getRunningSessionPid()
260{
261 SessionInfos candidates;
262 const auto availableSessionInfos = KDevelop::SessionController::availableSessionInfos();
263 for (const KDevelop::SessionInfo& si : availableSessionInfos) {
264 if( KDevelop::SessionController::isSessionRunning(si.uuid.toString()) ) {
265 candidates << si;
266 }
267 }
268 if ( candidates.isEmpty() ) {
269 return -1;
270 }
271
272 QString sessionUuid;
273 if ( candidates.size() == 1 ) {
274 sessionUuid = candidates.first().uuid.toString();
275 }
276 else {
277 const QString title = i18n("Select the session to open the document in");
278 sessionUuid = KDevelop::SessionController::showSessionChooserDialog(title, true);
279 }
280 return KDevelop::SessionController::sessionRunInfo(sessionUuid).holderPid;
281}
282
283static QString findSessionId(const SessionInfos& availableSessionInfos, const QString& session)
284{

Callers 1

mainFunction · 0.85

Calls 4

toStringMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected