[Digikam-devel] Re: Logic error

Andi Clemens Andi.Clemens at gmx.net
Mon Nov 22 15:54:26 GMT 2010


But don't you have to declare it "virtual" again in all derived classes, although the base class already defined it like this?

If not, I guess we can skip all QObject / QWidget related classes, when I'm home I will check which classes remain if these types are ommitted.

Andi

-------- Original-Nachricht --------
> Datum: Mon, 22 Nov 2010 09:59:39 +0100
> Von: Marcel Wiesweg <marcel.wiesweg at gmx.de>
> An: "digiKam developers room - digiKam - Manage your photographs as a\\ 	professional with the power of open source" <digikam-devel at kde.org>
> Betreff: [Digikam-devel] Re: Logic error

> 
> > Basically since we inherit from QWidget most of the time, a virtual
> > destructor should always be used, since QWidget provides virtual
> methods?
> 
> Yes, any QObject-derived class will already have a virtual destructor.
> 
> The simple rule is "make your destructor virtual if your class has any
> virtual 
> functions":
> http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7
> 
> As far as I see GCC always gives a warning if you have virtual methods and
> not 
> virtual destructor in a base class
> 
> There is a small group of classes which will not need a virtual
> destructor: If 
> a class has a private QSharedDataPointer d-pointer, then it will usually
> not 
> be subclassed and not be created on the heap.
> And fast "inline" classes, like DColor, shouldnt have this.
> 
> > Like I said I converted every destructor to be virtual in my branch and
> I
> > can not see any slowdowns.
> 
> I would say there is the "slowdown" of the indirect call through the
> vtable, 
> which should be negligible in most cases. For memory cost, I think every 
> object will get an additional pointer.
> 
> The question is, which classes remain if you keep aside all
> QObject-derived 
> ones, which have it already, and all implictly/explicily-shared classes,
> which 
> dont need it?
> 
> Marcel
> _______________________________________________
> Digikam-devel mailing list
> Digikam-devel at kde.org
> https://mail.kde.org/mailman/listinfo/digikam-devel

-- 
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome



More information about the Digikam-devel mailing list