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

Function openProjectInRunningInstance

app/main.cpp:236–255  ·  view source on GitHub ↗

Performs a DBus call to open the given @p files in the running kdev instance identified by @p pid Returns the exit status

Source from the content-addressed store, hash-verified

234/// Performs a DBus call to open the given @p files in the running kdev instance identified by @p pid
235/// Returns the exit status
236static int openProjectInRunningInstance(const QVector<UrlInfo>& paths, qint64 pid)
237{
238 const QString service = QStringLiteral("org.kdevelop.kdevelop-%1").arg(pid);
239 QDBusInterface iface(service, QStringLiteral("/org/kdevelop/ProjectController"), QStringLiteral("org.kdevelop.ProjectController"));
240 int errors = 0;
241
242 for (const UrlInfo& path : paths) {
243 QDBusReply<void> result = iface.call(QStringLiteral("openProjectForUrl"), path.url.toString());
244 if ( !result.isValid() ) {
245 QTextStream err(stderr);
246 err << i18n("Could not open project '%1': %2", path.url.toDisplayString(QUrl::PreferLocalFile), result.error().message()) << "\n";
247 ++errors;
248 }
249 }
250 // make the window visible
251 QDBusMessage makeVisible = QDBusMessage::createMethodCall( service, QStringLiteral("/kdevelop/MainWindow"), QStringLiteral("org.kdevelop.MainWindow"),
252 QStringLiteral("ensureVisible") );
253 QDBusConnection::sessionBus().asyncCall( makeVisible );
254 return errors;
255}
256
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.

Callers 1

mainFunction · 0.85

Calls 4

toStringMethod · 0.45
isValidMethod · 0.45
messageMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected