Re: [[gtkmm] Glib::RefPtr also for Widgets?]



> in my experience, it is extremely dangerous for many widgets, at least
> in gtk+ 1.2 and its matching gtkmm version.

Is "many widgets" some well defined set of widgets, or you mean "most
widgets I used"?

> AFAIK, no extra reference is taken during signal emission, so the
> "delete this" will delete the memory used by the widget for whom the
> signal emission is taking place. most likely it works for you because
> you don't have a multithreaded program or one where memory allocation
> might happen after the "delete this" but before the end of signal
> emission.

I have multithreaded program, but only the main thread uses gtk/gtkmm.
Other threads are workers only. And what do you mean by "one where memory
allocation might happen after the "delete this" but before the end of
signal emission" ? Of course 'delete this' is called in main thread where
windows are created and signals are handled, and of course when I delete
this object I don't alloc any memory in this thread. But other threads are
free to do it and they surely do allocs.

> deleting a widget during a signal emission is just a bad idea, IMHO.

You can always do a little trick:
In signal handler add a timer callback and bind 'this' pointer as a param
to the callback, and the only thing that callback does is 'delete param'
:)

Could you provide a simple example when 'delete this' causes troubles?

Jarek


----------------------------------------------------------------------
Wykorzystaj mnie... >>> http://link.interia.pl/f1654





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]