Bug 55235 - Gtk.TreeView.get_Model() throws NullReferenceException
Summary: Gtk.TreeView.get_Model() throws NullReferenceException
Status: RESOLVED FIXED
Alias: None
Product: Gtk#
Classification: Mono
Component: gtk-sharp ()
Version: 2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-04-15 09:49 UTC by Mirco Bauer
Modified: 2017-04-15 19:00 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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mirco Bauer 2017-04-15 09:49:07 UTC
When upgrading from GTK# 2.12.10 to 2.12.40 I started to see exceptions in Smuxi 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

The code that accesses the TreeView model in this case can be seen here:

https://github.com/meebey/smuxi/blob/stable/src/Frontend-GNOME/Views/Chats/GroupChatView.cs#L325

It reads the property (which initially always works I think) and then it overwrites the value. If the chat get's re-populated via Populate() then it sometimes throws the exception as seen above.

This has never been a problem though with GTK# < 2.12.40

In the GTK# 2.12 branch I can see a fix/change related to this code:
https://github.com/mono/gtk-sharp/commit/4ac71507fffce997207215ac3f8b38471ce60a14

Is that potentially fixing this specific issue? If so, I will backport that fix to the Debian package.
Comment 1 Mirco Bauer 2017-04-15 09:57:53 UTC
One minute before that exception there were multiple Gtk CRITICAL messages shown on the console:

Apr 11 08:09:52 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): Gtk-CRITICAL **: IA__gtk_list_store_clear: assertion 'GTK_IS_LIST_STORE (list_store)' failed
Apr 11 08:09:59 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): Gtk-CRITICAL **: IA__gtk_tree_view_set_model: assertion 'model == NULL || GTK_IS_TREE_MODEL (mode
l)' failed
Apr 11 08:09:59 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Apr 11 08:10:50 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): Gtk-CRITICAL **: IA__gtk_list_store_clear: assertion 'GTK_IS_LIST_STORE (list_store)' failed
Apr 11 08:10:56 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): GLib-GObject-CRITICAL **: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
Apr 11 08:10:56 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): GLib-GObject-CRITICAL **: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
Apr 11 08:10:56 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): GLib-GObject-CRITICAL **: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
Apr 11 08:10:56 flyinghorse smuxi-frontend-gnome.desktop[1992]: (smuxi-frontend-gnome:1992): GLib-GObject-CRITICAL **: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
Comment 2 Mirco Bauer 2017-04-15 10:24:15 UTC
If I leave Model as it is, instead of replacing it, the issue is no longer reproducible and there are no more Gtk CRITICAL messages.
Comment 3 Marius Ungureanu 2017-04-15 19:00:16 UTC
This is fixed by 4ac71507fffce997207215ac3f8b38471ce60a14