Changeset View
Changeset View
Standalone View
Standalone View
app/main.cpp
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
115 | public: | 115 | public: | ||
116 | explicit KDevelopApplication(int &argc, char **argv, bool GUIenabled = true) | 116 | explicit KDevelopApplication(int &argc, char **argv, bool GUIenabled = true) | ||
117 | #if KDEVELOP_SINGLE_APP | 117 | #if KDEVELOP_SINGLE_APP | ||
118 | : SharedTools::QtSingleApplication(QStringLiteral("KDevelop"), argc, argv) | 118 | : SharedTools::QtSingleApplication(QStringLiteral("KDevelop"), argc, argv) | ||
119 | #else | 119 | #else | ||
120 | : QApplication(argc, argv, GUIenabled) | 120 | : QApplication(argc, argv, GUIenabled) | ||
121 | #endif | 121 | #endif | ||
122 | { | 122 | { | ||
123 | #if KDEVELOP_SINGLE_APP | | |||
124 | Q_UNUSED(GUIenabled); | 123 | Q_UNUSED(GUIenabled); | ||
125 | #endif | | |||
126 | | ||||
127 | connect(this, &QGuiApplication::saveStateRequest, this, &KDevelopApplication::saveState); | 124 | connect(this, &QGuiApplication::saveStateRequest, this, &KDevelopApplication::saveState); | ||
128 | } | 125 | } | ||
129 | 126 | | |||
130 | #if KDEVELOP_SINGLE_APP | 127 | #if KDEVELOP_SINGLE_APP | ||
131 | public Q_SLOTS: | 128 | public Q_SLOTS: | ||
132 | void remoteArguments(const QString &message, QObject *socket) | 129 | void remoteArguments(const QString &message, QObject *socket) | ||
133 | { | 130 | { | ||
134 | Q_UNUSED(socket); | 131 | Q_UNUSED(socket); | ||
Show All 26 Lines | 157 | if (KDevelop::Core::self() && KDevelop::Core::self()->sessionController()) { | |||
161 | QString x11SessionId = QString("%1_%2").arg(sm.sessionId()).arg(sm.sessionKey()); | 158 | QString x11SessionId = QString("%1_%2").arg(sm.sessionId()).arg(sm.sessionKey()); | ||
162 | const auto activeSession = KDevelop::Core::self()->sessionController()->activeSession(); | 159 | const auto activeSession = KDevelop::Core::self()->sessionController()->activeSession(); | ||
163 | if (!activeSession) { | 160 | if (!activeSession) { | ||
164 | qWarning() << "No active session, can't save state"; | 161 | qWarning() << "No active session, can't save state"; | ||
165 | return; | 162 | return; | ||
166 | } | 163 | } | ||
167 | 164 | | |||
168 | QString kdevelopSessionId = activeSession->id().toString(); | 165 | QString kdevelopSessionId = activeSession->id().toString(); | ||
169 | sm.setRestartCommand(QStringList() << QCoreApplication::applicationFilePath() << "-session" << x11SessionId << "-s" << kdevelopSessionId); | 166 | sm.setRestartCommand({QCoreApplication::applicationFilePath(), "-session", x11SessionId, "-s", kdevelopSessionId}); | ||
170 | } | 167 | } | ||
171 | } | 168 | } | ||
172 | }; | 169 | }; | ||
173 | 170 | | |||
174 | /// Tries to find a session identified by @p data in @p sessions. | 171 | /// Tries to find a session identified by @p data in @p sessions. | ||
175 | /// The @p data may be either a session's name or a string-representation of its UUID. | 172 | /// The @p data may be either a session's name or a string-representation of its UUID. | ||
176 | /// @return pointer to the session or NULL if nothing appropriate has been found | 173 | /// @return pointer to the session or NULL if nothing appropriate has been found | ||
177 | static const KDevelop::SessionInfo* findSessionInList( const SessionInfos& sessions, const QString& data ) | 174 | static const KDevelop::SessionInfo* findSessionInList( const SessionInfos& sessions, const QString& data ) | ||
Show All 28 Lines | 201 | if ( ! result.value() ) { | |||
206 | err << i18n("Could not open file %1.", file.url.toDisplayString(QUrl::PreferLocalFile)) << "\n"; | 203 | err << i18n("Could not open file %1.", file.url.toDisplayString(QUrl::PreferLocalFile)) << "\n"; | ||
207 | errors_occured = true; | 204 | errors_occured = true; | ||
208 | } | 205 | } | ||
209 | } | 206 | } | ||
210 | // make the window visible | 207 | // make the window visible | ||
211 | QDBusMessage makeVisible = QDBusMessage::createMethodCall( service, "/kdevelop/MainWindow", "org.kdevelop.MainWindow", | 208 | QDBusMessage makeVisible = QDBusMessage::createMethodCall( service, "/kdevelop/MainWindow", "org.kdevelop.MainWindow", | ||
212 | "ensureVisible" ); | 209 | "ensureVisible" ); | ||
213 | QDBusConnection::sessionBus().asyncCall( makeVisible ); | 210 | QDBusConnection::sessionBus().asyncCall( makeVisible ); | ||
214 | return errors_occured ? 1 : 0; | 211 | return errors_occured; | ||
215 | } | 212 | } | ||
216 | 213 | | |||
217 | /// Gets the PID of a running KDevelop instance, eventually asking the user if there is more than one. | 214 | /// Gets the PID of a running KDevelop instance, eventually asking the user if there is more than one. | ||
218 | /// Returns -1 in case there are no running sessions. | 215 | /// Returns -1 in case there are no running sessions. | ||
219 | static qint64 getRunningSessionPid() | 216 | static qint64 getRunningSessionPid() | ||
220 | { | 217 | { | ||
221 | SessionInfos candidates; | 218 | SessionInfos candidates; | ||
222 | foreach( const KDevelop::SessionInfo& si, KDevelop::SessionController::availableSessionInfos() ) { | 219 | foreach( const KDevelop::SessionInfo& si, KDevelop::SessionController::availableSessionInfos() ) { | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 303 | if (infoDict) { | |||
308 | CFDictionarySetValue(infoDict, CFSTR("NSAppSleepDisabled"), kCFBooleanTrue); | 305 | CFDictionarySetValue(infoDict, CFSTR("NSAppSleepDisabled"), kCFBooleanTrue); | ||
309 | CFDictionarySetValue(infoDict, CFSTR("NSSupportsAutomaticTermination"), kCFBooleanFalse); | 306 | CFDictionarySetValue(infoDict, CFSTR("NSSupportsAutomaticTermination"), kCFBooleanFalse); | ||
310 | } | 307 | } | ||
311 | } | 308 | } | ||
312 | #endif | 309 | #endif | ||
313 | 310 | | |||
314 | static const char description[] = I18N_NOOP( "The KDevelop Integrated Development Environment" ); | 311 | static const char description[] = I18N_NOOP( "The KDevelop Integrated Development Environment" ); | ||
315 | KAboutData aboutData( "kdevelop", i18n( "KDevelop" ), QByteArray(VERSION), i18n(description), KAboutLicense::GPL, | 312 | KAboutData aboutData( "kdevelop", i18n( "KDevelop" ), QByteArray(VERSION), i18n(description), KAboutLicense::GPL, | ||
316 | i18n("Copyright 1999-2016, The KDevelop developers"), QString(), "http://www.kdevelop.org/"); | 313 | i18n("Copyright 1999-2017, The KDevelop developers"), QString(), "https://www.kdevelop.org/"); | ||
317 | aboutData.setDesktopFileName(QStringLiteral("org.kde.kdevelop.desktop")); | 314 | aboutData.setDesktopFileName(QStringLiteral("org.kde.kdevelop.desktop")); | ||
318 | aboutData.addAuthor( i18n("Kevin Funk"), i18n( "Co-maintainer, C++/Clang, QA, Windows Support" ), "kfunk@kde.org" ); | 315 | aboutData.addAuthor( i18n("Kevin Funk"), i18n( "Co-maintainer, C++/Clang, QA, Windows Support" ), "kfunk@kde.org" ); | ||
319 | aboutData.addAuthor( i18n("Sven Brauch"), i18n( "Co-maintainer, AppImage, Python Support, User Interface improvements" ), "svenbrauch@gmail.com" ); | 316 | aboutData.addAuthor( i18n("Sven Brauch"), i18n( "Co-maintainer, AppImage, Python Support, User Interface improvements" ), "svenbrauch@gmail.com" ); | ||
320 | aboutData.addAuthor( i18n("Aleix Pol Gonzalez"), i18n( "CMake Support, Run Support, Kross Support" ), "aleixpol@gmail.com" ); | 317 | aboutData.addAuthor( i18n("Aleix Pol Gonzalez"), i18n( "CMake Support, Run Support, Kross Support" ), "aleixpol@gmail.com" ); | ||
321 | aboutData.addAuthor( i18n("Milian Wolff"), i18n( "C++/Clang, Generic manager, Webdevelopment Plugins, Snippets, Performance" ), "mail@milianw.de" ); | 318 | aboutData.addAuthor( i18n("Milian Wolff"), i18n( "C++/Clang, Generic manager, Webdevelopment Plugins, Snippets, Performance" ), "mail@milianw.de" ); | ||
322 | aboutData.addAuthor( i18n("Olivier JG"), i18n( "C++/Clang, DUChain, Bug Fixes" ), "olivier.jg@gmail.com" ); | 319 | aboutData.addAuthor( i18n("Olivier JG"), i18n( "C++/Clang, DUChain, Bug Fixes" ), "olivier.jg@gmail.com" ); | ||
323 | aboutData.addAuthor( i18n("Andreas Pakulat"), i18n( "Architecture, VCS Support, Project Management Support, QMake Projectmanager" ), "apaku@gmx.de" ); | 320 | aboutData.addAuthor( i18n("Andreas Pakulat"), i18n( "Architecture, VCS Support, Project Management Support, QMake Projectmanager" ), "apaku@gmx.de" ); | ||
324 | aboutData.addAuthor( i18n("Alexander Dymo"), i18n( "Architecture, Sublime UI, Ruby support" ), "adymo@kdevelop.org" ); | 321 | aboutData.addAuthor( i18n("Alexander Dymo"), i18n( "Architecture, Sublime UI, Ruby support" ), "adymo@kdevelop.org" ); | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
382 | QStringList debugArgs; | 379 | QStringList debugArgs; | ||
383 | QString debugeeName; | 380 | QString debugeeName; | ||
384 | { | 381 | { | ||
385 | bool debugFound = false; | 382 | bool debugFound = false; | ||
386 | int c = argc; | 383 | int c = argc; | ||
387 | for (int i=0; i < c; ++i) { | 384 | for (int i=0; i < c; ++i) { | ||
388 | if (debugFound) { | 385 | if (debugFound) { | ||
389 | debugArgs << argv[i]; | 386 | debugArgs << argv[i]; | ||
390 | } else if (qstrcmp(argv[i], "--debug") == 0 || qstrcmp(argv[i], "-d") == 0) { | 387 | } else if ((qstrcmp(argv[i], "--debug") == 0) || (qstrcmp(argv[i], "-d") == 0)) { | ||
391 | if (argc <= i+1) { | 388 | if (argc > (i + 1)) { | ||
392 | argc = i + 1; | | |||
393 | } else { | | |||
394 | i++; | 389 | i++; | ||
395 | argc = i + 1; | | |||
396 | } | 390 | } | ||
391 | argc = i + 1; | ||||
397 | debugFound = true; | 392 | debugFound = true; | ||
398 | } else if (QString(argv[i]).startsWith("--debug=")) { | 393 | } else if (QString(argv[i]).startsWith("--debug=")) { | ||
399 | argc = i + 1; | 394 | argc = i + 1; | ||
400 | debugFound = true; | 395 | debugFound = true; | ||
401 | } | 396 | } | ||
402 | } | 397 | } | ||
403 | } | 398 | } | ||
404 | 399 | | |||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Line(s) | 617 | if(parser.isSet("pid")) { | |||
641 | } else { | 636 | } else { | ||
642 | qCritical() << sessionData->uuid.toString() << sessionData->name << "is not running"; | 637 | qCritical() << sessionData->uuid.toString() << sessionData->name << "is not running"; | ||
643 | return 5; | 638 | return 5; | ||
644 | } | 639 | } | ||
645 | } | 640 | } | ||
646 | 641 | | |||
647 | KDevIDEExtension::init(); | 642 | KDevIDEExtension::init(); | ||
648 | 643 | | |||
649 | if(!Core::initialize(nullptr, Core::Default, session)) | 644 | if(!Core::initialize(Core::Default, session)) | ||
650 | return 5; | 645 | return 5; | ||
651 | 646 | | |||
652 | // register a DBUS service for this process, so that we can open files in it from other invocations | 647 | // register a DBUS service for this process, so that we can open files in it from other invocations | ||
653 | QDBusConnection::sessionBus().registerService(QString("org.kdevelop.kdevelop-%1").arg(app.applicationPid())); | 648 | QDBusConnection::sessionBus().registerService(QString("org.kdevelop.kdevelop-%1").arg(app.applicationPid())); | ||
654 | 649 | | |||
655 | // TODO: port to kf5 | 650 | // TODO: port to kf5 | ||
656 | // KGlobal::locale()->insertCatalog( Core::self()->componentData().catalogName() ); | 651 | // KGlobal::locale()->insertCatalog( Core::self()->componentData().catalogName() ); | ||
657 | Core* core = Core::self(); | 652 | Core* core = Core::self(); | ||
658 | if (!QProcessEnvironment::systemEnvironment().contains("KDEV_DISABLE_WELCOMEPAGE")) { | 653 | if (!QProcessEnvironment::systemEnvironment().contains("KDEV_DISABLE_WELCOMEPAGE")) { | ||
659 | core->pluginController()->loadPlugin("KDevWelcomePage"); | 654 | core->pluginController()->loadPlugin("KDevWelcomePage"); | ||
660 | } | 655 | } | ||
661 | 656 | | |||
662 | QStringList projectNames = parser.values("project"); | 657 | QStringList projectNames = parser.values("project"); | ||
663 | if(!projectNames.isEmpty()) | 658 | foreach(const QString& projectName, projectNames) | ||
664 | { | | |||
665 | foreach(const QString& p, projectNames) | | |||
666 | { | 659 | { | ||
667 | QFileInfo info( p ); | 660 | QFileInfo info( projectName ); | ||
668 | if( info.suffix() == "kdev4" ) { | 661 | if( info.suffix() == "kdev4" ) { | ||
669 | // make sure the project is not already opened by the session controller | 662 | // make sure the project is not already opened by the session controller | ||
670 | bool shouldOpen = true; | 663 | bool shouldOpen = true; | ||
671 | Path path(info.absoluteFilePath()); | 664 | Path path(info.absoluteFilePath()); | ||
672 | foreach(KDevelop::IProject* p, core->projectController()->projects()) { | 665 | foreach(KDevelop::IProject* project, core->projectController()->projects()) { | ||
673 | if (p->projectFile() == path) { | 666 | if (project->projectFile() == path) { | ||
674 | shouldOpen = false; | 667 | shouldOpen = false; | ||
675 | break; | 668 | break; | ||
676 | } | 669 | } | ||
677 | } | 670 | } | ||
678 | if (shouldOpen) { | 671 | if (shouldOpen) { | ||
679 | core->projectController()->openProject( path.toUrl() ); | 672 | core->projectController()->openProject( path.toUrl() ); | ||
680 | } | 673 | } | ||
681 | } | 674 | } | ||
682 | } | 675 | } | ||
683 | } | | |||
684 | 676 | | |||
685 | if ( parser.isSet("debug") ) { | 677 | const QString debugStr = QStringLiteral("debug"); | ||
678 | if ( parser.isSet(debugStr) ) { | ||||
686 | Q_ASSERT( !debugeeName.isEmpty() ); | 679 | Q_ASSERT( !debugeeName.isEmpty() ); | ||
687 | QString launchName = debugeeName; | 680 | QString launchName = debugeeName; | ||
688 | 681 | | |||
689 | KDevelop::LaunchConfiguration* launch = nullptr; | 682 | KDevelop::LaunchConfiguration* launch = nullptr; | ||
690 | qCDebug(APP) << launchName; | 683 | qCDebug(APP) << launchName; | ||
691 | foreach (KDevelop::LaunchConfiguration *l, core->runControllerInternal()->launchConfigurationsInternal()) { | 684 | foreach (KDevelop::LaunchConfiguration *l, core->runControllerInternal()->launchConfigurationsInternal()) { | ||
692 | qCDebug(APP) << l->name(); | 685 | qCDebug(APP) << l->name(); | ||
693 | if (l->name() == launchName) { | 686 | if (l->name() == launchName) { | ||
Show All 11 Lines | |||||
705 | } | 698 | } | ||
706 | if (!type) { | 699 | if (!type) { | ||
707 | QTextStream qerr(stderr); | 700 | QTextStream qerr(stderr); | ||
708 | qerr << endl << i18n("Cannot find native launch configuration type") << endl; | 701 | qerr << endl << i18n("Cannot find native launch configuration type") << endl; | ||
709 | return 1; | 702 | return 1; | ||
710 | } | 703 | } | ||
711 | 704 | | |||
712 | if (launch && launch->type()->id() != "Native Application") launch = nullptr; | 705 | if (launch && launch->type()->id() != "Native Application") launch = nullptr; | ||
713 | if (launch && launch->launcherForMode("debug") != parser.value("debug")) launch = nullptr; | 706 | if (launch && launch->launcherForMode(debugStr) != parser.value(debugStr)) launch = nullptr; | ||
714 | if (!launch) { | 707 | if (!launch) { | ||
715 | qCDebug(APP) << launchName << "not found, creating a new one"; | 708 | qCDebug(APP) << launchName << "not found, creating a new one"; | ||
716 | QPair<QString,QString> launcher; | 709 | QPair<QString,QString> launcher; | ||
717 | launcher.first = "debug"; | 710 | launcher.first = debugStr; | ||
718 | foreach (KDevelop::ILauncher *l, type->launchers()) { | 711 | foreach (KDevelop::ILauncher *l, type->launchers()) { | ||
719 | if (l->id() == parser.value("debug")) { | 712 | if (l->id() == parser.value(debugStr)) { | ||
720 | if (l->supportedModes().contains("debug")) { | 713 | if (l->supportedModes().contains(debugStr)) { | ||
721 | launcher.second = l->id(); | 714 | launcher.second = l->id(); | ||
722 | } | 715 | } | ||
723 | } | 716 | } | ||
724 | } | 717 | } | ||
725 | if (launcher.second.isEmpty()) { | 718 | if (launcher.second.isEmpty()) { | ||
726 | QTextStream qerr(stderr); | 719 | QTextStream qerr(stderr); | ||
727 | qerr << endl << i18n("Cannot find launcher %1", parser.value("debug")) << endl; | 720 | qerr << endl << i18n("Cannot find launcher %1", parser.value(debugStr)) << endl; | ||
728 | return 1; | 721 | return 1; | ||
729 | } | 722 | } | ||
730 | KDevelop::ILaunchConfiguration* ilaunch = core->runController()->createLaunchConfiguration(type, launcher, nullptr, launchName); | 723 | KDevelop::ILaunchConfiguration* ilaunch = core->runController()->createLaunchConfiguration(type, launcher, nullptr, launchName); | ||
731 | launch = dynamic_cast<KDevelop::LaunchConfiguration*>(ilaunch); | 724 | launch = dynamic_cast<KDevelop::LaunchConfiguration*>(ilaunch); | ||
732 | } | 725 | } | ||
733 | 726 | | |||
734 | type->configureLaunchFromCmdLineArguments(launch->config(), debugArgs); | 727 | type->configureLaunchFromCmdLineArguments(launch->config(), debugArgs); | ||
735 | launch->config().writeEntry("Break on Start", true); | 728 | launch->config().writeEntry("Break on Start", true); | ||
736 | core->runControllerInternal()->setDefaultLaunch(launch); | 729 | core->runControllerInternal()->setDefaultLaunch(launch); | ||
737 | 730 | | |||
738 | core->runControllerInternal()->execute("debug", launch); | 731 | core->runControllerInternal()->execute(debugStr, launch); | ||
739 | } else { | 732 | } else { | ||
740 | openFiles(initialFiles); | 733 | openFiles(initialFiles); | ||
741 | } | 734 | } | ||
742 | 735 | | |||
743 | #if KDEVELOP_SINGLE_APP | 736 | #if KDEVELOP_SINGLE_APP | ||
744 | // Set up remote arguments. | 737 | // Set up remote arguments. | ||
745 | QObject::connect(&app, &SharedTools::QtSingleApplication::messageReceived, | 738 | QObject::connect(&app, &SharedTools::QtSingleApplication::messageReceived, | ||
746 | &app, &KDevelopApplication::remoteArguments); | 739 | &app, &KDevelopApplication::remoteArguments); | ||
Show All 18 Lines |