Bug 3610 - Inconsistence in Build method which is automatically created for a Gtk.Window
Summary: Inconsistence in Build method which is automatically created for a Gtk.Window
Status: NEW
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: GTK# Designer ()
Version: 2.8.6
Hardware: PC Windows
: Low normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 2108 ()
Depends on:
Blocks:
 
Reported: 2012-02-23 10:34 UTC by just4tests
Modified: 2012-04-24 13:24 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 3610 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description just4tests 2012-02-23 10:34:36 UTC
Description of Problem:

When I use the provided visual designer from MonoDevelop (C#) ver. 2.8.6.5, to create a Window with callbacks for the following signals: show, shown and realized, nothing happens when the window is showed. It seems that the signals are never raised.

Steps to reproduce the problem:
0. Create a new Gtk+ application.
1. Create a window.
2. Add callbacks for signals that are used at the beginning of the window lifecycle: realize, show, shown.
3. Make sure that the window is showed when application starts.
4. Start application.

Actual Results:
The signals are not raised.

Expected Results:
The signals should be raised. And the callbacks should be executed in a defined order.

How often does this happen? 
Everytime.

Additional Information:
Here is a code strip from the Build method (which is automatically generated):

this.DefaultWidth = 400;
this.DefaultHeight = 300;
this.Show ();
this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
this.Shown += new global::System.EventHandler (this.OnShown);
this.Realized += new global::System.EventHandler (this.OnRealized);
this.quitAction.Activated += new global::System.EventHandler(this.OnQuitActionActivated);

After seeing the above code, the cause is obvious: this.Show() is called before the handlers are assigned to events.

To solve this, I changed the position of the Show method call to the end of the build method like this:

this.DefaultWidth = 400;
this.DefaultHeight = 300;

this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
this.Shown += new global::System.EventHandler (this.OnShown);
this.Realized += new global::System.EventHandler (this.OnRealized);
this.quitAction.Activated += new global::System.EventHandler(this.OnQuitActionActivated);

this.Show ();
Comment 1 Jeffrey Stedfast 2012-04-24 13:24:11 UTC
*** Bug 2108 has been marked as a duplicate of this bug. ***