[Gtk-sharp-list] Gnome.About instance after pressing the OK button

John Luke jluke@cfl.rr.com
15 Jun 2003 12:18:49 -0400


I may be misunderstanding the issue but ...
I think the normal way to Show a dialog is with Gtk.Dialog.Run ();

copy & paste from Monodoc:

Waits for the Response event or the Dialog to be destroyed. If the
Dialog is destroyed during the call to Run (), Dialog returns None.
Otherwise, it returns the response ID from the Response event. Before
entering the recursive main loop, Run () calls Show () on the Dialog for
you. Note that you still need to show any children of the Dialog
        During Run (), the default behavior of DeleteEvent is disabled;
        if the Dialog receives DeleteEvent, it will not be destroyed as
        usual, and Run () will return DeleteEvent. Also, during Run ()
        the Dialog will be modal. You can force Run () to return at any
        time by calling Respond to emit the Response event. Destroying
        the Dialog during Run () is a very bad idea, because your
        post-run code will not know whether the Dialog was destroyed or
        After Run () returns, you are responsible for hiding or
        destroying the Dialog if you wish to do so.

Hope this helps,
John Luke

On Sun, 2003-06-15 at 11:34, Philip Van Hoof wrote:
> I think that if you create an instance of the Gnome.About and the user
> presses "Ok" on that window; that the instance is left incorrectly. I
> think that the Raw variable used internally in gtk-sharp is left
> unintialized because Gtk+ will destroy that object in memory after the
> [Ok] button has been pressed..
> It's possible that I am wrong here, so please first check.
> Solution .. gtk-sharp should connect to the Response and Close events
> and destroy the object "this" ...
> What I tested was this :
> public class Something
> {
>   Gnome.About ab;
>   public Something () {
>   }
>   private void OnAboutButtonClicked (object o, EventArgs args) {
> 	if (ab == null) {
> 	    ab = new Gnome.About (.....);
>             ...
>         }    
>         ab.Show();
>   }
> }
> What I expected was that ab would be null once and the other times I
> click that Button it would use the existing instance. In stead this
> throws an NullPointerException. My best guess is that ab the second time
> won't be null but the internal object "Raw" of Gnome.About has been
> destroyed because the user pressed "Ok".