how to make a wxMessageDialog() go away programmatically??
Posted: Mon May 01, 2017 6:03 am
I am using wxWidgets to create a front-end GUI that interacts via wxSockets with a remote TCP server.
I create a wxMessageDialog(), and do a ShowModal() on that object to display it.
So far, so good. As expected, it appears to be running the event loop inside the Modal dialog, and not the main wxWidgets event loop.
Fortunately, I still receive events in the handler I connected to my TCP client socket.
Depending on the TCP message that I receive, I would like to programmatically remove the wxMessageDialog, and not wait for the user to
press a button on the Dialog.
The TCP message handler does a dialog->EndModal(0). However, this seems to do nothing to the dialog. It is still there on the screen,
the rest of the GUI is unresponsive, and debug-print statements after the call to ShowModal() do not print anything.
Any suggestions on how to get a wxMessageDialog() to go away programmatically from inside a socket message handler?
One thing that "worked": After the ShowModal(), I do a dialog->Destroy(). This makes the dialog disappear, and the rest of the GUI becomes
available again. However, I see a sequence of ugly and alarming warning messages in the xterminal window:
(lua:7495): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(lua:7495): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(lua:7495): Gtk-CRITICAL **: IA__gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed
(lua:7495): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(I am using the wxLua wrapper for wxWidgets.)
Is it "ok" to do the dialog->Destroy() in this situation, even though the EndModal() did not seem to have any effect?
Thanks VERY MUCH for any guidance or assistance.
Greg Johnson
I create a wxMessageDialog(), and do a ShowModal() on that object to display it.
So far, so good. As expected, it appears to be running the event loop inside the Modal dialog, and not the main wxWidgets event loop.
Fortunately, I still receive events in the handler I connected to my TCP client socket.
Depending on the TCP message that I receive, I would like to programmatically remove the wxMessageDialog, and not wait for the user to
press a button on the Dialog.
The TCP message handler does a dialog->EndModal(0). However, this seems to do nothing to the dialog. It is still there on the screen,
the rest of the GUI is unresponsive, and debug-print statements after the call to ShowModal() do not print anything.
Any suggestions on how to get a wxMessageDialog() to go away programmatically from inside a socket message handler?
One thing that "worked": After the ShowModal(), I do a dialog->Destroy(). This makes the dialog disappear, and the rest of the GUI becomes
available again. However, I see a sequence of ugly and alarming warning messages in the xterminal window:
(lua:7495): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(lua:7495): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(lua:7495): Gtk-CRITICAL **: IA__gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed
(lua:7495): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
(I am using the wxLua wrapper for wxWidgets.)
Is it "ok" to do the dialog->Destroy() in this situation, even though the EndModal() did not seem to have any effect?
Thanks VERY MUCH for any guidance or assistance.
Greg Johnson