[kdev 4] isn't this dangerous?

Andreas Pakulat apaku at gmx.de
Fri Apr 20 15:23:32 UTC 2007


On 20.04.07 07:27:21, Matt Rogers wrote:
> On Friday 20 April 2007 05:59, Jens Herden wrote:
> > Hi,
> >
> > I found this code in lib/interfaces/iplugin.cpp:
> >
> >
> > 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*
> >
> > Or is there a reason why we can not do this?
> >
> > Jens
> 
> It would be safer. I don't know why we couldn't do this. Hopefully, Alexander 
> or Andreas can explain better

Because the instances are not created by us. We can only give a QObject
to KServiceTypeTrader::createInstanceFromQuery as parent. 

Andreas

-- 
You will meet an important person who will help you advance professionally.




More information about the KDevelop-devel mailing list