Bug 318693 (MONO75757) - GTK Widget has no "destroy_event", call "destroy" instead it.
Summary: GTK Widget has no "destroy_event", call "destroy" instead it.
Status: RESOLVED INVALID
Alias: MONO75757
Product: gtk#
Classification: Mono
Component: other (show other bugs)
Version: unspecified
Hardware: Other Linux
: P3 - Medium : Major
Target Milestone: ---
Assignee: Gtk# Bugs List
QA Contact: Gtk# Bugs List
URL:
Whiteboard:
Keywords: UI
Depends on:
Blocks:
 
Reported: 2005-08-09 09:43 UTC by Gediminas Bukauskas
Modified: 2007-09-15 21:23 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Sample MONOdevelop project, demonstrating this bug (4.53 KB, application/octet-stream)
2005-08-09 09:46 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:27:02 UTC


---- Reported by audriusb@homelan.lt 2005-08-09 02:43:53 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:
   GTK widget has "destroy" event. You are connecting "destroy_event"
(Widget.cs, public event Gtk.DestroyEventHandler DestroyEvent). This bug
generates applications without calling DestroyEventHandler (try attached
sample).

Steps to reproduce the problem:
1. Generate GTK application with MonoDevelop.
2. Initialize Destroy event in window constructor: this.DestroyEvent += new
DestroyEventHandler(onMyWindowDestroy);
3. Move "Application.Quit ();" into DestroyEventHandler.

Actual Results:
  Closing main window does not finish the program, you must enter Ctrl+c
from terminal to finish it.

Expected Results:


How often does this happen? 


Additional Information:



---- Additional Comments From audriusb@homelan.lt 2005-08-09 02:46:23 MST ----

Created an attachment (id=168336)
Sample MONOdevelop project, demonstrating this bug




---- Additional Comments From audriusb@homelan.lt 2005-08-09 03:43:28 MST ----

Sorry, name of the attachement is invalid. Save it as "sample.tar.gz".



---- Additional Comments From mkestner@ximian.com 2005-09-06 14:45:55 MST ----

I think you want DeleteEvent, if you are looking for how to close down
applications from a window manager decoration.



---- Additional Comments From audriusb@homelan.lt 2005-09-09 01:44:57 MST ----

No, GTK+ has 2 different events:
  GDK_DELETE - request to close main window; it occurs when main window
               is active and programmer should write validation code
               here (ask "Are you sure?", check resources, ...); it is
               possible to cancel window closing in this handler.
  GDK_DESTROY - this event is raised AFTER main window was destroyed;
               task finishing code should be written here.
Tested GTK# version never calls GDK_DESTROY event handler because it
supplies name: "destroy_event". You must to change it into "destroy".



---- Additional Comments From mkestner@ximian.com 2005-09-09 10:53:40 MST ----

No, the correct signal name is Widget::destroy_event.  There is no
Widget::destroy signal.  You may be confusing it with
Gtk.Object::destroy, which is mapped to the Object.Destroyed event in
Gtk# because of a collision with the Destroy method.



---- Additional Comments From audriusb@homelan.lt 2005-09-10 03:29:58 MST ----

Look at the GTK+ tutor:
  http://www.gtk.org/tutorial/c58.html#SEC-HELLOWORLD

/* Here we connect the "destroy" event to a signal handler.  
 * This event occurs when we call gtk_widget_destroy() on the window,
 * or if we return FALSE in the "delete_event" callback. */
    g_signal_connect (G_OBJECT (window), "destroy",
		      G_CALLBACK (destroy), NULL);

  The fact is that GTK# never calls "destroy" event, because is using
invalid handler's name:"destroy_event". MONO develop met this bug and
moved finalization code into "delete_event", but this is very serious
error: there are many situations when request for closing of main
window is not last message in the queue. Messages from threads, timer,
window manager and user defined messages may follow it. Calling 
gtk_main_quit () in "delete_event" you'll destroy non empty message
queue and this will make GTK# programms incompatible with GNOME.
  Don't waste a time for stupid discussions and correct this bug:
GNOME programmers will never use GTK# otherwise.



---- Additional Comments From mkestner@ximian.com 2005-09-10 11:22:50 MST ----

The "destroy" signal that is emited in response to gtk_widget_destroy
is the GtkObject::destroy signal.  gtk_widget_destroy does nothing but
call gtk_object_destroy.

As I said in my last comment, if you want the "destroy" signal you
want the Gtk.Object.Destroyed event in Gtk#.

If you look at the source or the documentation for GtkWidget, you will
see that it has a destroy_event signal, but no destroy signal other
than the inherited GtkObject signal.

Imported an attachment (id=168336)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>UBUNTU HOARY for AMD64</cf_op_sys_details>
Unknown bug field "cf_version_details" encountered while moving bug
   <cf_version_details>gtk-sharp-2.5.5</cf_version_details>