| 78 | } |
| 79 | |
| 80 | void Plugin::launchHeaptrack() |
| 81 | { |
| 82 | IExecutePlugin* executePlugin = nullptr; |
| 83 | |
| 84 | // First we should check that our "kdevexecute" plugin is loaded. This is needed since |
| 85 | // current plugin controller logic allows us to unload this plugin with keeping dependent |
| 86 | // plugins like Heaptrack in "loaded" state. This seems to be wrong behaviour but now we have |
| 87 | // to do additional checks. |
| 88 | // TODO fix plugin controller to avoid such inconsistent states. |
| 89 | auto pluginController = core()->pluginController(); |
| 90 | if (auto plugin = pluginController->pluginForExtension( |
| 91 | QStringLiteral("org.kdevelop.IExecutePlugin"), QStringLiteral("kdevexecute"))) { |
| 92 | executePlugin = plugin->extension<IExecutePlugin>(); |
| 93 | } else { |
| 94 | auto pluginInfo = pluginController->infoForPluginId(QStringLiteral("kdevexecute")); |
| 95 | postErrorMessage(i18n("Unable to start Heaptrack analysis - \"%1\" plugin is not loaded.", pluginInfo.name())); |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | auto runController = KDevelop::Core::self()->runControllerInternal(); |
| 100 | auto defaultLaunch = runController->defaultLaunch(); |
| 101 | if (!defaultLaunch) { |
| 102 | runController->showConfigurationDialog(); |
| 103 | defaultLaunch = runController->defaultLaunch(); |
| 104 | if (!defaultLaunch) { |
| 105 | postErrorMessage(i18n("Configure a native application launch to perform Heaptrack analysis on.")); |
| 106 | return; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | if (!defaultLaunch->type()->launcherForId(QStringLiteral("nativeAppLauncher"))) { |
| 111 | postErrorMessage(i18n("Heaptrack analysis can be started only for native applications.")); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | auto heaptrackJob = new Job(defaultLaunch, executePlugin); |
| 116 | connect(heaptrackJob, &Job::finished, this, &Plugin::jobFinished); |
| 117 | runController->registerJob(makeJobWithDependency(heaptrackJob, *executePlugin, defaultLaunch)); |
| 118 | |
| 119 | m_launchAction->setEnabled(false); |
| 120 | } |
| 121 | |
| 122 | void Plugin::attachHeaptrack() |
| 123 | { |
nothing calls this directly
no test coverage detected