| 281 | } |
| 282 | |
| 283 | static QString findSessionId(const SessionInfos& availableSessionInfos, const QString& session) |
| 284 | { |
| 285 | //If there is a session and a project with the same name, always open the session |
| 286 | //regardless of the order encountered |
| 287 | QString projectAsSession; |
| 288 | for (const KDevelop::SessionInfo& si : availableSessionInfos) { |
| 289 | if ( session == si.name || session == si.uuid.toString() ) { |
| 290 | return si.uuid.toString(); |
| 291 | } else if (projectAsSession.isEmpty()) { |
| 292 | for (const QUrl& k : si.projects) { |
| 293 | QString fn(k.fileName()); |
| 294 | fn = fn.left(fn.indexOf(QLatin1Char('.'))); |
| 295 | if ( session == fn ) { |
| 296 | projectAsSession = si.uuid.toString(); |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | if (projectAsSession.isEmpty()) { |
| 303 | QTextStream qerr(stderr); |
| 304 | qerr << QLatin1Char('\n') << i18n("Cannot open unknown session %1. See `--list-sessions` switch for available sessions or use `-n` to create a new one.", |
| 305 | session) << QLatin1Char('\n'); |
| 306 | } |
| 307 | return projectAsSession; |
| 308 | } |
| 309 | |
| 310 | static qint64 findSessionPid(const QString &sessionId) |
| 311 | { |