[smuxi/stable] Frontend-GNOME: fix MissingMethodException



commit b5d0972a7125717921ec9469bc1d2fa0ff722dad
Author: Mirco Bauer <meebey meebey net>
Date:   Fri Jun 4 10:16:25 2021 +0800

    Frontend-GNOME: fix MissingMethodException
    
    This is fix is similar to e0464410b746012325beee706f1340ddcff1a653
    
    Avoid using Gtk.TreeIter.Equals(TreeIter) as the method is not always available
    and can crash at runtime like this:
    
        Inner-Exception Type:
        System.MissingMethodException
    
        Inner-Exception Message:
        Method not found: bool Gtk.TreeIter.Equals(Gtk.TreeIter)
    
        Inner-Exception StackTrace:
          at (wrapper managed-to-native) 
System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
          at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags 
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo 
culture) [0x00044] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
    
        Exception Type:
        System.Reflection.TargetInvocationException
    
        Exception Message:
        Exception has been thrown by the target of an invocation.
    
        Exception StackTrace:
          at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags 
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo 
culture) [0x0005f] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x0010d] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x0000b] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x0001e] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in 
<d0e12f672b88444ab4b6d9b2ecf20142>:0
          at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x0006d] in 
<5a439e0caae7469886e7119d9f6bc621>:0
          at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x0000c] in 
<5a439e0caae7469886e7119d9f6bc621>:0
          at GLib.SignalClosure.MarshalCallback (System.IntPtr raw_closure, System.IntPtr return_val, 
System.UInt32 n_param_vals, System.IntPtr param_values, System.IntPtr invocation_hint, System.IntPtr 
marshal_data) [0x0006c] in <5a439e0caae7469886e7119d9f6bc621>:0

 src/Frontend-GNOME/Views/ChatTreeView.cs | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/ChatTreeView.cs b/src/Frontend-GNOME/Views/ChatTreeView.cs
index c6b842d8..68efce42 100644
--- a/src/Frontend-GNOME/Views/ChatTreeView.cs
+++ b/src/Frontend-GNOME/Views/ChatTreeView.cs
@@ -96,15 +96,16 @@ namespace Smuxi.Frontend.Gnome
             Selection.Mode = Gtk.SelectionMode.Browse;
             Selection.Changed += (sender, e) => {
                 Gtk.TreeIter iter;
-                if (!Selection.GetSelected(out iter) &&
-                    TreeStore.GetIterFirst(out iter)) {
+                if (!Selection.GetSelected(out iter)) {
+                    // select the first chat view if none is selected
+                    if (!TreeStore.GetIterFirst (out iter)) {
+                        // no chat views available, nothing to do; this happens during shutdown
+                        return;
+                    }
                     Selection.SelectIter(iter);
                     return;
                 }
-                if (Gtk.TreeIter.Zero.Equals(iter)) {
-                    // no chat views available; this happens during shutdown
-                    return;
-                }
+
                 var path = TreeStore.GetPath(iter);
                 f_CurrentChatNumber = GetRowNumber(path);
             };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]