[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Debug plugin load weirdness
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2009-07-15 22:02:21
Message-ID: 20090715220221.GD5912 () trinity ! apaku ! dnsalias ! org
[Download RAW message or body]

Hi,

I've got a small problem here with a kdevelop plugin (the C++ support in
fact). The plugin works just fine when loaded into kdevelop as do all
the other plugins we have. Unfortunately it seems that somehow the
KComponentData for the plugins factory (created via K_PLUGIN_FACTORY)
gets corrupted when loading the plugin from a unit-test.

The unit-test itself can load other plugins from kdevelop just fine, its
just the c++ plugin that does things differently somehow causing such a
break. The symptom is a simple crash on setXMLFile (plugins are xmlgui
clients) and thats because setXMLFile tries to access the
componentName() of the factory, but the KComponentData it gets from
KDevCppSupportFactory::componentData() is invalid.

I've replaced the K_PLUGIN_FACTORY macro call with the actual code and
it seems that somewhere between creation of the factory via
K_EXPORT_PLUGIN and the call to KDevCppSupportFactory::componentData in
the actual plugin class constructor (handing it over to xmlguiclient)
there's a breakage of the global static thats allocated for this
componentdata object. 

I'm calling KDevCppSupportFactory::componentData() from the
KDevCppSupportFactory constructor and get one pointer and later on from
the CppLanguageSupport constructor the pointer printed in
componentData() is something else (and thats not initialized).

My debug code for this is currently:

,----
> // This is what K_PLUGIN_FACTORY gets expanded to
> K_GLOBAL_STATIC(KComponentData, KDevCppSupportFactoryfactorycomponentdata)
> 
> class KDevCppSupportFactory : public KPluginFactory
> {
> public:
> explicit KDevCppSupportFactory( const char * cname = 0, const char* caname = 0, \
> QObject* parent = 0 )
> > KPluginFactory(cname, caname, parent ) { init(); }
> explicit KDevCppSupportFactory( const KAboutData& aboutData, QObject* parent = 0 )
> > KPluginFactory( aboutData, parent ) { qDebug() << "creating with about \
> > data";init(); qDebug() << "data valid?" << \
> > KDevCppSupportFactory::componentData().isValid(); }
> ~KDevCppSupportFactory(){}
> static KComponentData componentData() {
> qDebug() << KDevCppSupportFactoryfactorycomponentdata << \
> KDevCppSupportFactoryfactorycomponentdata->isValid();
> return *KDevCppSupportFactoryfactorycomponentdata;
> }
> 
> private:
> void init() {
> qDebug() << "factory:" << KDevCppSupportFactoryfactorycomponentdata << \
> KDevCppSupportFactoryfactorycomponentdata->isValid();
> if( KDevCppSupportFactoryfactorycomponentdata->isValid() ) {
> setComponentData(*KDevCppSupportFactoryfactorycomponentdata);
> } else {
> qDebug() << "assigning: " << KPluginFactory::componentData().componentName();
> *KDevCppSupportFactoryfactorycomponentdata = KPluginFactory::componentData();
> }
> qDebug() << "factory" << KDevCppSupportFactoryfactorycomponentdata << \
> KDevCppSupportFactoryfactorycomponentdata->isValid();
> registerPlugin<CppLanguageSupport>();
> qDebug() << "factory" << KDevCppSupportFactoryfactorycomponentdata << \
> KDevCppSupportFactoryfactorycomponentdata->isValid();
> }
> };
> 
> //K_PLUGIN_FACTORY(KDevCppSupportFactory, registerPlugin<CppLanguageSupport>(); )
> // Create an instance of the factory
> K_EXPORT_PLUGIN(KDevCppSupportFactory(KAboutData("kdevcppsupport","kdevcpp", \
> ki18n("C++ Support"), "0.1", ki18n("Support for C++ Language"), \
> KAboutData::License_GPL)))
> 
> // Just a way to know when componentData() is called from the constructor
> KComponentData getCompData()
> {
> qDebug() << "returning for iplugin constructor";
> return KDevCppSupportFactory::componentData();
> }
> 
> CppLanguageSupport::CppLanguageSupport( QObject* parent, const QVariantList& \
> /*args*/ )
> > KDevelop::IPlugin( getCompData(), parent ),
> 
> //IPlugin just forwards its componentdata to XMLGuiClient. Its a subclass of \
> QObject+XMLGuiClient.
`----

The output I get is:
QDEBUG : TestCppCodegen::initTestCase() creating with about data
QDEBUG : TestCppCodegen::initTestCase() factory: 0x8312e38 false
QDEBUG : TestCppCodegen::initTestCase() assigning:  "kdevcppsupport"
QDEBUG : TestCppCodegen::initTestCase() factory 0x8312e38 true
QDEBUG : TestCppCodegen::initTestCase() factory 0x8312e38 true
QDEBUG : TestCppCodegen::initTestCase() 0x8312e38 true
QDEBUG : TestCppCodegen::initTestCase() data valid? true
QDEBUG : TestCppCodegen::initTestCase() returning for iplugin constructor
QDEBUG : TestCppCodegen::initTestCase() 0x8329cd0 false

So somehow the global static pointer is being changed, or there are two
different statics allocated somehow (no idea how that can happen). Anybody with
an idea?

Andreas

-- 
You are standing on my toes.
 
> > Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic