Re: Gtk::Widget::destory() ?





I want to show the progress of downloads (running as threads). If a new
download starts, a new instance of ProgressBar is allocated on heap and
added to the VBox. When a download finishes, the related ProgressBar
should be removed from the VBox and since there is no need for it any
longer also destroyed. At the moment I using gtk_widget_detroy:

    gtk_widget_destroy((GtkWidget*)pPgb->gobj());

This isn't how gtkmm does things.  Almost always, you should never call delete, or destroy on an object. (There are always exceptions, but this isn't one.)

The way to do this is when you create your progress bar, do it like this:

Gtk::Progressbar* pbar = Gtk::manage( new Gtk::ProgressBar() ) ;

vbox->add( *pbar ) ;

..../* Magically time passes */...

vbox->remove( *pbar ) ;

At this point it should be destroyed automatically.

Paul


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