[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 17:18:45
Message-ID: 200812221818.48040.mail () milianw ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Am Montag 22 Dezember 2008 schrieb Andreas Pakulat:
> On 22.12.08 14:12:09, Milian Wolff wrote:
> > Here a follow up to this issue:
> >
> > I severely doubt the X-KDE-PluginInfo-Depends is taken into account when
> > loading or deleting KTextEditor plugins. Attached you'll find two very
> > simple KTextEditorPlugins, parent and child. Obviously child depends on
> > parent. The Plugin configuration screen works fine, i.e. when I enable
> > child it makes sure parent gets enabled as well. So far so good.
> >
> > Now enable both, apply and quit kwrite. You'll notice some debug output
> > on the
> >
> > console. For me it looks like this:
> > > $ kwrite
> > > kwrite(12991) ParentPlugin::ParentPlugin: Parent Plugin setup.
> > > kwrite(12991) ChildPlugin::ChildPlugin: Child Plugin setup, Parent
> > > should
> >
> > have been setup already!
> >
> > > kwrite(12991) ParentPlugin::~ParentPlugin: Parent Plugin destroyed!
> > > kwrite(12991) ChildPlugin::~ChildPlugin: Child Plugin destroyed, Parent
> >
> > plugin must not be destroyed yet!
> >
> > Parent is setup before child, which is good. But parent also gets
> > destroyed before child which is of course bad. I can imagine tons of
> > usecases where a child needs to tell the base it is destroyed, i.e. base
> > should _never ever_ be destroyed before any of its children!
> >
> > And to make things worse: I've just added a second child to my kte_linter
> > plugin in playground and that one gets loaded _before_ my base class.
> > Since it tries to tell the base class that it got loaded kwrite & kate
> > segfault everytime I start them.
> >
> > So: Could someone look into the algorithm for setting up these plugins
> > and make sure the -depends stuff is taken into account? Or at least tell
> > me where this would take place and I could have a look.
>
> kdelibs/utils/katepartpluginmanager.cpp looks like the right place for
> KTextEditor plugins (i.e. stuff that loads in kwrite). kate plugins are
> managed by something in kdesdk/kate.


Indeed, kdelibs/kate/utils/katepartpluginmanager.cpp looks like the right 
place to look. And as I've feared there is no X-KDE-PluginInfo-Depends check 
at all! I'd try to implement that, but need more information:

1. can X-KDE-PluginInfo-Depends contain more than one plugin? I.e. comma 
separated list?
2. I'd need to adapt loadPlugin and unloadPlugin, and check that the 
dependencies are fullfilled (i.e. unload dependent plugins before base plugin, 
load base plugin before dependent plugin).
3. What's with enablePlugin / disablePlugin?


Regarding the implementation: The simplest and least-code-intensive algorithm 
would be the following, though I don't think it's very optimal (from a 
performance standpoint):

The following is pseudo-code & c++ mish-mash:

void loadPlugin ( KatePartPluginInfo &item ) {
        // how do I do that: API hint?
        readPluginConfig;

	if (X-KDE-PluginInfo-Depends not empty) {
		foreach( plugin in m_pluginList ) {
			if ( plugin->saveName() == X-KDE-PluginInfo-Depends ) {
				loadPlugin ( plugin );
				break;
				// maybe even set a boolean to make sure we fullfilled the dependency
				// so we don't load a plugin whose dependency is unknown
			}
		}
	}
	// normal loadPlugin code
}

Analogous for unloadPlugin. Why I'm not very happy here is because I have to 
traverse the whole m_pluginList for every plugin with a dependency.

And regarding the readPluginConfig, can I do KatePartPluginInfo->service-
>property("X-KDE-PluginInfo-Depends").toString() ?

[1]: http://api.kde.org/4.x-api/kdelibs-
apidocs/kate/html/classKatePartPluginInfo.html#81ec3edd2510e2dd2dacc77194ab62dd

-- 
Milian Wolff
mail@milianw.de
http://milianw.de

["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