mirror of
				https://github.com/Ryujinx/GtkSharp.git
				synced 2025-11-04 08:24:56 +00:00 
			
		
		
		
	gtk: Fix a KeyNotFoundException regression in Destroyed event
The migration to generic collections [1] caused another regression: a
KeyNotFoundException was being thrown (instead of returning null like
HashTable did) when using the Destroyed event of the Gtk.Widget class.
[1] 6850b343ca
A particular example of this problem is Banshee's Import Media feature,
which was generating the following stacktrace:
[1 Debug 23:24:36.898] Starting - Importing Media
Marshaling activate signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException
to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Collections.Generic.KeyNotFoundException: The given key was not
present in the dictionary.
  at System.Collections.Generic.Dictionary`2[System.IntPtr,System.Delegate].get_Item
(IntPtr key) [0x00000] in <filename unknown>:0
  at Gtk.Widget.add_Destroyed (System.EventHandler value) [0x00000] in
/home/knocte/gtk-sharp/gtk/Widget.cs:333
  at Hyena.Widgets.AnimatedWidget..ctor (Gtk.Widget widget, UInt32
duration, Easing easing, Blocking blocking, Boolean horizontal)
[0x0004d] in /home/knocte/banshee/src/Hyena/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs:78
			
			
This commit is contained in:
		
							parent
							
								
									2388d09bb7
								
							
						
					
					
						commit
						7ce1457c13
					
				| 
						 | 
				
			
			@ -330,11 +330,15 @@ namespace Gtk {
 | 
			
		|||
		[GLib.Signal("destroy")]
 | 
			
		||||
		public event EventHandler Destroyed {
 | 
			
		||||
			add {
 | 
			
		||||
				EventHandler handler = (EventHandler) DestroyHandlers [Handle];
 | 
			
		||||
				Delegate delegate_handler;
 | 
			
		||||
				DestroyHandlers.TryGetValue (Handle, out delegate_handler);
 | 
			
		||||
				var handler = delegate_handler as EventHandler;
 | 
			
		||||
				DestroyHandlers [Handle] = Delegate.Combine (handler, value);
 | 
			
		||||
			}
 | 
			
		||||
			remove {
 | 
			
		||||
				EventHandler handler = (EventHandler) DestroyHandlers [Handle];
 | 
			
		||||
				Delegate delegate_handler;
 | 
			
		||||
				DestroyHandlers.TryGetValue (Handle, out delegate_handler);
 | 
			
		||||
				var handler = delegate_handler as EventHandler;
 | 
			
		||||
				handler = (EventHandler) Delegate.Remove (handler, value);
 | 
			
		||||
				if (handler != null)
 | 
			
		||||
					DestroyHandlers [Handle] = handler;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue