webservjava
asked on
Pressing "x" button in a GTK window.
When I press the corner "X" button in a GTK+ window (I usse libglade) the window closes and I cannot reopen it. GTK complains that "file gtkwidget.c: line 1427 (gtk_widget_show): assertion `widget != NULL' failed." It appears that clicking on the "x" makes the pointer "NULL".
akshay is right
>>file gtkwidget.c: line 1427 (gtk_widget_show): assertion `widget != NULL' failed."
appears that you closed the window but did not free up the space i.e. did not "destroy" it ....
the pointer would still be holding the address of previous widgets....
while closing the window, free the space you have allocated and set the pointers to NULL
>>file gtkwidget.c: line 1427 (gtk_widget_show): assertion `widget != NULL' failed."
appears that you closed the window but did not free up the space i.e. did not "destroy" it ....
the pointer would still be holding the address of previous widgets....
while closing the window, free the space you have allocated and set the pointers to NULL
if u r using glad or not .. it will be simple .. just make sure to set gtk_widget_destroy as the call back for the 'x' button of window .. as i suppose u dont want to use it anymore...
OR keep a global handle of the window .. and when u want to show it again .. check it the handle is not NULL then call only gtk_widget_show . instead of creating the same window again .. this helps in cases like u have a FILE selection dialog .. and u expect to use it many times.. then every time u close it .. just hide it .. and create it at the start of the application ..and gtk_widget_show it everytime u want to show it..
OR keep a global handle of the window .. and when u want to show it again .. check it the handle is not NULL then call only gtk_widget_show . instead of creating the same window again .. this helps in cases like u have a FILE selection dialog .. and u expect to use it many times.. then every time u close it .. just hide it .. and create it at the start of the application ..and gtk_widget_show it everytime u want to show it..
ASKER
Yes, I do use glade and It did not help to use delete_event or gtk_widget_destroy or setting the popup window to NULL.
Here is the callback:
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr orbox);
filefoferrorbox = NULL;
return TRUE;
}
OR:
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr orbox);
return TRUE;
}
Here is the callback:
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr
filefoferrorbox = NULL;
return TRUE;
}
OR:
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr
return TRUE;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
filefoferrorbox is a GnomeMessageBox and therefore has no parent.
copy paste around 10 lines of code before and after line 1427
my guess is that in the callback
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr orbox);
filefoferrorbox = NULL; <<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<< <
return TRUE;
}
you set filefoferrorbox to NULL and then you try to access it in line 1427
my guess is that in the callback
gboolean fof_delete_event(void)
{
gtk_widget_hide(filefoferr
filefoferrorbox = NULL; <<<<<<<<<<<<<<<<<<<<<<<<<<
return TRUE;
}
you set filefoferrorbox to NULL and then you try to access it in line 1427
tell me the callback that u have registered on that 'x' button .. did u use glade for developing ?..