Re: [gtk-list] Gtk--: RFyC: gtk-- experiences (1 year of usage)
- From: Tero Pulkkinen <terop assari cc tut fi>
- To: gtk-list redhat com
- cc: gtkmm modeemi cs tut fi
- Subject: Re: [gtk-list] Gtk--: RFyC: gtk-- experiences (1 year of usage)
- Date: 27 Jan 1999 16:14:46 +0200
Christof Petig <christof.petig@wtal.de> writes:
> *Some assorted Gtk-- experiences*
>
> o Never try to copy a Widget. This might change in future revisions of
> gtk-- (>0.10). But up to now it is lethal. So avoid:
> o widget=other_widget; and vector<Gtk_Widget>.push_back(widget);.
> [[Havoc]] explains in detail what is going wrong. Instead use
> vector<Gtk_Widget*>.push_back(new Gtk_Widget());.
>
> I have been told ([[Tero, Sep 98]]) that vector<auto_ptr<Gtk_Widget>>
> should provide even more enhanced functionality but I haven't found any
> docu about these new gtk-- features, yet!
hmm, I'm not really sure if auto_ptr<> is any better for exactly this
situation. Safest bet right now is use vector<Gtk_Widget*> myvec; and have
destructor delete the objects. (seems that it'd really need to be
refcouted pointer object, if you want to store it in vector<> -- auto_ptr
can invalidate the pointer silently => not good for a vector<>. :)
However, Gtk_Container provides way to do this:
auto_ptr<Gtk_Widget> buttonwidget(new Gtk_Button);
add(buttonwidget);
or use pack_start/pack_end or other insertion methods of different
Gtk_Container's. This "Gtk_ObjectHandle<>" interface for these methods
were added to avoid forcing people to store objects they only
construct and then forget... => now the only code that needs to know
about the objects are constructor adding the widget to container. The
Gtk_Container will handle deletion of objects inserted to the
container that way. There is no documentation of this feature - and
you should use it carefully and report all bugs... .) (== it has not
been used much.)
> o Deleting a widget tree has issues. So far calling hide() and then
> deleting the widget should be safe for windows/dialogs. But this is only
> safe for widgets which are not contained within another widget (e.g. a
> Box). Gtk-- has no gtk_container_remove equivalent, yet.
yup. The thing we should do is to add support for STL's container requirements
for these cases... (erase method...)
> o You might work around deleting widgets by hiding them and reusing them
> (ugh!)
yuck:)
> o You cannot delete a Widget while processing a callback from it. For me
> the following works:
wasnt there added that delete_self() method? maybe it works?
(anyway, I'll look into the other issues from the mail later.. :)
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]