Commit d5e17b94 authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

Document that PluginLoader should be a singleton.

The kipi-plugins use the instance() method, and the constructor
sets up `s_instance` .. this class should be a singleton,
but was not being used as one by Spectacle, leading to crashes.
parent 2fa92a18
...@@ -60,6 +60,9 @@ class ConfigWidget; ...@@ -60,6 +60,9 @@ class ConfigWidget;
\class PluginLoader \class PluginLoader
This is the class that will help host applications to load plugins. This is the class that will help host applications to load plugins.
This is a singleton and host applications should create the PluginLoader
just once, and then use the instance() static method to access it.
The host application must create an instance of the plugin loader, and The host application must create an instance of the plugin loader, and
call the method loadPlugins() to get the plugins loaded. To ensure that call the method loadPlugins() to get the plugins loaded. To ensure that
plugins are correctly removed from menus and toolbars when loaded and plugins are correctly removed from menus and toolbars when loaded and
...@@ -139,6 +142,7 @@ class ConfigWidget; ...@@ -139,6 +142,7 @@ class ConfigWidget;
this, SLOT(slotKipiPluginPlug())); this, SLOT(slotKipiPluginPlug()));
m_loader->loadPlugins(); m_loader->loadPlugins();
// Do not delete m_loader as long as any of the plugins are in use
} }
void MyKipiApplication::slotKipiPluginPlug() void MyKipiApplication::slotKipiPluginPlug()
...@@ -226,18 +230,28 @@ public: ...@@ -226,18 +230,28 @@ public:
public: public:
/** /**
* Use this constructor if your application does not use KDE XML GUI technology * Use this constructor if your application does not use KDE XML GUI technology.
*
* Note that the PluginLoader is intended to be a singleton, so you
* should create only one and then use instance().
*/ */
PluginLoader(); PluginLoader();
/** /**
* Standard constructor. You must pass the instance of KDE XML GUI application as argument. * Standard constructor. You must pass the instance of KDE XML GUI application as argument.
*
* Note that the PluginLoader is intended to be a singleton, so you
* should create only one and then use instance().
*
* @param parent the pointer to the KXmlGuiWindow of your application * @param parent the pointer to the KXmlGuiWindow of your application
*/ */
PluginLoader(KXmlGuiWindow* const parent); PluginLoader(KXmlGuiWindow* const parent);
/** /**
* Standard destructor * Standard destructor
*
* Since PluginLoader is a singleton, you should not call this
* in client code.
*/ */
~PluginLoader() override; ~PluginLoader() override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment