[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Re: X-KDE-PluginInfo-Depends not working for KTextEditor Plugins?
From: Milian Wolff <mail () milianw ! de>
Date: 2008-12-22 19:33:22
Message-ID: 200812222033.28631.mail () milianw ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Attached you can find a patch for katepartpluginmanager.cpp:
It properly loads dependencies and unloads dependent plugins beforehand. I'm
still unsure whether the implementation is OK from a performance standpoint.
And of course I'd love to see a code review. I've added some questions in the
code comments. Also I'm unsure whether a Q_ASSERT( openDependencies.empty() )
is OK.
If the patch is OK I can commit it to trunk. But can I also backport it to the
KDE4.2 branch? I mean it's a bugfix in my eyes... If I should backport it, how
would I do that? I've once read about a script which does just that. Cannot
find it documented on techbase though.
Oh and here's a message Rafael Fernández López send to me:
Am Montag 22 Dezember 2008 schrieb Rafael Fernández López:
> Hi,
>
> > Great, thanks. I'll try to get a working patch written. One question
> > though: Why is neither the dependencies() method nor the relationship to
> > KPluginInfo mentioned in the API documentation of KatePartPluginInfo [1]
> > ?
> >
> > [1]: http://api.kde.org/4.x-api/kdelibs-
> > apidocs/kate/html/classKatePartPluginInfo.html#81ec3edd2510e2dd2dacc77194
> >ab 62dd
>
> Well, KatePartPluginInfo does not inherit KPluginInfo. What you can do as I
> see, is that KatePartPluginInfo is this:
>
> class KatePartPluginInfo
> {
> public:
> mutable bool load;
> KService::Ptr service;
> KTextEditor::Plugin *plugin;
> QString saveName() const;
> };
>
> You can get a KPluginInfo this way:
>
> KPluginInfo pluginInfo(partPluginInfo.service); (check KPluginInfo
> documentation, it has a constructor taking a service).
>
> Later you can get dependencies through:
>
> pluginInfo.dependencies();
I've used what he suggested and it worked like a charm. Thanks Rafael!
--
Milian Wolff
mail@milianw.de
http://milianw.de
["katepartpluginmanager_dependencies.patch" (text/x-patch)]
Index: utils/katepartpluginmanager.cpp
===================================================================
--- utils/katepartpluginmanager.cpp (Revision 900386)
+++ utils/katepartpluginmanager.cpp (Arbeitskopie)
@@ -30,6 +30,7 @@
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kxmlguifactory.h>
+#include <kplugininfo.h>
#include <kservicetypetrader.h>
#include <kdebug.h>
@@ -184,6 +185,25 @@ void KatePartPluginManager::loadPlugin (
{
if (item.plugin) return;
+ // make sure all dependencies are loaded beforehand
+ QStringList openDependencies = KPluginInfo( item.service ).dependencies();
+ if ( !openDependencies.empty() )
+ {
+ for (KatePartPluginList::iterator it = m_pluginList.begin();
+ it != m_pluginList.end(); ++it)
+ {
+ if ( openDependencies.contains( it->saveName() ) )
+ {
+ // 1) do I have to check it->load like loadAllPlugins does?
+ // 2) I don't have to check for circular references, right? I mean if
+ // someone does that the infinite loop should be easily spotted.
+ loadPlugin( *it );
+ openDependencies.removeAll( it->saveName() );
+ }
+ }
+ Q_ASSERT( openDependencies.empty() );
+ }
+
item.plugin = KTextEditor::createPlugin (item.service, this);
Q_ASSERT(item.plugin);
item.load = (item.plugin != 0);
@@ -191,6 +211,22 @@ void KatePartPluginManager::loadPlugin (
void KatePartPluginManager::unloadPlugin (KatePartPluginInfo &item)
{
+ // is this ok? Or should it be item.plugin == O ? Or !item.plugin ?
+ // or should I check item.load ?
+ if ( item.plugin == 0L ) return;
+
+ // make sure dependent plugins are unloaded beforehand
+ for (KatePartPluginList::iterator it = m_pluginList.begin();
+ it != m_pluginList.end(); ++it)
+ {
+ if ( it->plugin == 0L ) continue;
+
+ if ( KPluginInfo( it->service ).dependencies().contains( item.saveName() ) )
+ {
+ unloadPlugin( *it );
+ }
+ }
+
delete item.plugin;
item.plugin = 0L;
item.load = false;
["signature.asc" (application/pgp-signature)]
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic