How to delete object?!
- From: "Dmitry Ponomaryov" <eagleowl comail ru>
- To: <gtk-app-devel-list gnome org>
- Subject: How to delete object?!
- Date: Wed, 24 Jan 2001 16:53:23 +0300
Hi to All!
I need _true_ delete function for GTK widget (i.e. GtkWidget* pr_dialog; an
so on).
If I call "gtk_widget_destroy" memory belongs to object is't become free -
only object's ref count is decremented.
So I try this:
while( !GTK_OBJECT_DESTROYED( GTK_OBJECT(pr_dialog) ) )
gtk_object_unref( GTK_OBJECT(pr_dialog) );
or this:
while ( pr_dialog != NULL )
gtk_widget_unref( pr_dialog );
or this:
gtk_type_free( GTK_WIDGET_TYPE(pr_dialog), (gpointer)pr_dialog );
or:
gtk_type_free( GTK_DIALOG, (gpointer)pr_dialog );
But all fails - GTK loops forever or core dumped :-[
How can I do _true_ real delete routine for widget?
More info: my dialog is not packed into any other GtkWidget and it
works like the following:
1. create dialog with stuff;
2. if user press any dialog's button - _true_ delete dialog and
call user button's callback fucntion;
3. if user don't press any dialog's button but call dialog's creation
routine again don't create _new_ dialog, but show old one (in which
user don't press any button). [i.e. item 3. is so 'pseudo-modal mode' ]
Item 3. is like:
static GtkWidget* dialog = NULL;
if ( ! dialog )
{
dialog = gcp_dialog_new_show( /* dialog creation stuff - item 1.*/ );
/* my function gcp_dialog_new_show defines a callback for any dialog's
* button: true delete dialog and call user defined button's callback.
* i.e. this it item 2. */
}
else /* i.e. item 3. */
{
if ( ! GTK_WIDGET_MAPPED(dialog) )
gtk_widget_show( dialog );
else
gdk_window_raise( dialog->window );
}
But as I say - _true_ delete routine fails(I temporary replace it with
"gtk_widget_destroy"), so: when we get into "else" gialog is not NULL, but
it can't be neither showed ("gtk_widget_show" dump core) nor raise
("gdk_window_raise" dump core) since it's deleted with
"gtk_widget_destroy",
which is not _true_ delete function.
PS. If my explanation or my english is bad - let me now, I try again.
---
Dmitry Ponomaryov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]