[kdev 4] isn't this dangerous?

Alexander Dymo alexander.dymo at gmail.com
Fri Apr 20 12:56:21 UTC 2007


On 4/20/07, Jens Herden <jens at kdewebdev.org> wrote:
> IPlugin::IPlugin( const KComponentData &instance, QObject *parent )
>         : QObject( parent ),
>         KXMLGUIClient(), d( new IPluginPrivate )
> {
>     d->core = static_cast<KDevelop::ICore*>(parent);
>     setComponentData( instance );
> }
>
>
> and I wonder why we need the static_cast here. I think it would be saver to
> change the constructer to receive a KDevelop::ICore* instead of a QParent*

I don't think we can change the constructor because we use
KLibLoader::createInstance (called by
KServiceTypeTrader::createInstanceFromQuery which we use in plugin
loader) to instantiate plugins. createInstance sends QObject* as a
parent argument to the plugin's constructor, so it looks like we're
required to have this signature for the plugin's constructor with
QObject *parent there.

In our case static_cast is ok because plugin controller never sends
anything other than KDevelop::ICore pointer as an object.




More information about the KDevelop-devel mailing list