| 552 | } |
| 553 | |
| 554 | IPlugin *PluginController::loadPluginInternal( const QString &pluginId ) |
| 555 | { |
| 556 | Q_D(PluginController); |
| 557 | |
| 558 | QElapsedTimer timer; |
| 559 | timer.start(); |
| 560 | |
| 561 | KPluginMetaData info = infoForPluginId( pluginId ); |
| 562 | if ( !info.isValid() ) { |
| 563 | qCWarning(SHELL) << "Unable to find a plugin named '" << pluginId << "'!" ; |
| 564 | return nullptr; |
| 565 | } |
| 566 | |
| 567 | if ( IPlugin* plugin = d->loadedPlugins.value( info ) ) { |
| 568 | return plugin; |
| 569 | } |
| 570 | |
| 571 | const auto enabledState = d->enabledState(info); |
| 572 | if (enabledState < PluginControllerPrivate::FirstEnabledState) { |
| 573 | // Do not load disabled plugins |
| 574 | qCDebug(SHELL) << "Not loading plugin named" << pluginId << ( |
| 575 | (enabledState == PluginControllerPrivate::DisabledByEnv) ? |
| 576 | "because disabled by KDEV_DISABLE_PLUGINS." : |
| 577 | (enabledState == PluginControllerPrivate::DisabledBySetting) ? |
| 578 | "because disabled by setting." : |
| 579 | /* else, should not happen */ |
| 580 | "because disabled for unknown reason."); |
| 581 | return nullptr; |
| 582 | } |
| 583 | |
| 584 | if ( !hasMandatoryProperties( info ) ) { |
| 585 | qCWarning(SHELL) << "Unable to load plugin named" << pluginId << "because not all mandatory properties are set."; |
| 586 | return nullptr; |
| 587 | } |
| 588 | |
| 589 | if ( info.value(KEY_Mode()) == KEY_Gui() && Core::self()->setupFlags() == Core::NoUi ) { |
| 590 | qCDebug(SHELL) << "Not loading plugin named" << pluginId |
| 591 | << "- Running in No-Ui mode, but the plugin says it needs a GUI"; |
| 592 | return nullptr; |
| 593 | } |
| 594 | |
| 595 | qCDebug(SHELL) << "Attempting to load" << pluginId << "- name:" << info.name(); |
| 596 | |
| 597 | emit loadingPlugin( info.pluginId() ); |
| 598 | |
| 599 | // first, ensure all dependencies are available and not disabled |
| 600 | // this is unrelated to whether they are loaded already or not. |
| 601 | // when we depend on e.g. A and B, but B cannot be found, then we |
| 602 | // do not want to load A first and then fail on B and leave A loaded. |
| 603 | // this would happen if we'd skip this step here and directly loadDependencies. |
| 604 | if (const auto missingInterfaces = unresolvedDependencies(info); !missingInterfaces.empty()) { |
| 605 | qCWarning(SHELL) << "Can't load plugin" << pluginId |
| 606 | << "some of its required dependencies could not be fulfilled:" |
| 607 | << missingInterfaces.join(QLatin1Char(',')); |
| 608 | return nullptr; |
| 609 | } |
| 610 | |
| 611 | // now ensure all dependencies are loaded |
nothing calls this directly
no test coverage detected