[smuxi/stable] Frontend-GNOME: fix NullReferenceException thrown in GroupChatView.Populate()



commit c7c3ab070a3ac2fb7d7fdd94f8081f482359c363
Author: Mirco Bauer <meebey meebey net>
Date:   Sat Apr 15 22:20:34 2017 +0800

    Frontend-GNOME: fix NullReferenceException thrown in GroupChatView.Populate()
    
    On GTK# 2.12.40 there is a regression when the Gtk.TreeView.Model is replaced
    which leads to a NullReferenceException like this:
    
        System.NullReferenceException: Object reference not set to an instance of an object
         at GLib.GType.GetQualifiedName (System.String cname) [0x0005d] in 
<8c54b02ecd9b45db868abfb5696ef2d4>:0
         at GLib.GType.LookupType (System.IntPtr typeid) [0x00020] in <8c54b02ecd9b45db868abfb5696ef2d4>:0
         at GLib.ObjectManager.GetTypeOrParent (System.IntPtr obj) [0x00007] in 
<8c54b02ecd9b45db868abfb5696ef2d4>:0
         at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00012] in 
<8c54b02ecd9b45db868abfb5696ef2d4>:0
         at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00074] in 
<8c54b02ecd9b45db868abfb5696ef2d4>:0
         at Gtk.TreeModelAdapter.GetObject (System.IntPtr handle, System.Boolean owned) [0x00000] in 
<8bc02e9c110240acb0e1344122d80ad3>:0
         at Gtk.TreeView.get_Model () [0x0000c] in <8bc02e9c110240acb0e1344122d80ad3>:0
         at Smuxi.Frontend.Gnome.GroupChatView.Populate () [0x0004c] in 
/tmp/buildd/smuxi-1.0.6/src/Frontend-GNOME/Views/Chats/GroupChatView.cs:325
         at Smuxi.Frontend.Gnome.ChatViewManager+<OnChatSynced>c__AnonStorey1.<>m__0 () [0x0007b] in 
/tmp/buildd/smuxi-1.0.6/src/Frontend-GNOME/ChatViewManager.cs:351
         at GLib.Idle+IdleProxy.Handler (System.IntPtr data) [0x0003c] in <8c54b02ecd9b45db868abfb5696ef2d4>:0
    
    This issue is reported to GTK# upstream at:
    https://bugzilla.xamarin.com/show_bug.cgi?id=55235
    
    The fix is here to not do the micro-optimization of replacing the model but
    clearing and re-populating it in-place. With 2000 users this takes 200ms in
    total for Populate() without the optimization, but 150ms with the optimization.
    
    The optimization can be re-introduced later when the fixed GTK# version can be
    detected.

 src/Frontend-GNOME/Views/Chats/GroupChatView.cs |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/Chats/GroupChatView.cs b/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
index 1439168..e86ed57 100644
--- a/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
+++ b/src/Frontend-GNOME/Views/Chats/GroupChatView.cs
@@ -325,8 +325,6 @@ namespace Smuxi.Frontend.Gnome
                 Gtk.ListStore ls = (Gtk.ListStore) _PersonTreeView.Model;
                 // cleanup, be sure the list is empty
                 ls.Clear();
-                // detach the model (less CPU load)
-                _PersonTreeView.Model = new Gtk.ListStore(typeof(PersonModel));
                 Participants = new List<PersonModel>();
                 string longestName = String.Empty;
                 foreach (var person in persons.Values.OrderBy(x => x)) {
@@ -337,11 +335,6 @@ namespace Smuxi.Frontend.Gnome
                     }
                     Participants.Add(person);
                 }
-                // attach the model again
-                // BUG? TreeView doesn't seem to recognize existing values in the model?!?
-                // see: http://www.smuxi.org/issues/show/132
-                _PersonTreeView.Model = ls;
-                _PersonTreeView.SearchColumn = 0;
 
                 OnParticipantsChanged(EventArgs.Empty);
 


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