Re: [UFO-devel] BoUfo widget deleter
Status: Beta
Brought to you by:
schmidtjf
From: Andreas B. <b_...@gm...> - 2005-12-02 17:58:05
|
On Thursday 01 December 2005 15:33, Johannes Schmidt wrote: > Am Mittwoch 30 November 2005 23:52 schrieb Andreas Beckermann: > > Hi > > the attached patch is pretty controversial, but I decided to give it a > > try anyway. > > > > In Boson we cannot use libufo directly, due to > > a) conflicting toolkits > > b) different APIs > > Well, as may best please you. > > > Therefore I have written a BoUfo library that provides the required > > widgets in wrapper classes. However this solution has one major problem: > > destruction. A statement such as > > ufoWidget->removeAll(); > > would delete all ufo widgets, however not the corresponding wrapper > > objects. Therefore I have patched our libufo copy to introduce a "widget > > deleter". This is simply an object that is deleted at the beginning of > > the ufo::UWidget d'tor. Any class deriving from this class can do cleanup > > tasks that may be necessary before the widget actually is deleted. > > > > A normal ufo::UObject that is added to the widget using trackPointer() is > > _not_ sufficient, as this is deleted by the ufo::UObject d'tor only and > > at this point the ufo::UWidget has already been destroyed. > > Just a quick question: > Where do you actually use the UWidget pointer in your BoUfoWidget d'tor? > If haven't found any direct access to the UWidget object here: > http://cvs.sourceforge.net/viewcvs.py/boson/code/boson/boufo/boufowidget.cp >p?rev=1.9&view=markup The deleter does not do so at all (directly). It deletes the corresponding BoUfoWidget, which in turn uses the ufo::UWidget pointer or related pointers. This for example: http://cvs.sourceforge.net/viewcvs.py/boson/code/boson/boufo/bouforadiobutton.cpp?view=markup the d'tor uses the mButtonGroup pointer. That button group is deleted by the ufo::UButton that is encapsulated by the BoUfoWidget and therefore is deleted by the ufo::UWidget d'tor. Other (much more difficult to solve) examples can be found in the actual boson code. For example in the gameview/bosongameview.cpp > Regards, > Johannes CU Andi |