[Gtk-sharp-list] Crash when working with multiple TreeViews alongside WebView

Andorien andorien at gmail.com
Sun Jul 12 12:56:15 EDT 2009

So I'm trying to put together a simple RSS feed reader as sort of a personal
project.  It uses the standard design of a feed list to the left, a list of
articles on top, and the actual article being displayed on bottom.

The desired behavior is that selecting a feed will clear the article list of
any previous entries and populate it with the feed's articles.  Selecting an
article then loads the Webkit.WebView widget with the html string from the
article for display.

The crash occurs if you have a feed as well as an article already selected,
and you click another feed to select.  This causes an exception to be thrown
with the following text:
System.NullReferenceException: Object reference not set to an instance of an

It should be noted that this crash doesn't occur when selecting different
feeds as long as an article hasn't been selected yet.

Here are the relevant functions:
void OnFeedSelectionChanged(object o, EventArgs args)
	TreeSelection selection = (TreeSelection) o;
	TreeIter iter;
	selection.GetSelected(out iter);
	Feed feed = (Feed) FeedList.Model.GetValue(iter, 0);
	ItemList.View.Selection.UnselectAll(); // <-- Crash occurs at both this
function call and the next
	for(byte n = 0; n < feed.Items.Count; n++)

void OnItemSelectionChanged(object o, EventArgs args)
	TreeSelection selection = (TreeSelection) o;
	TreeIter iter;
	selection.GetSelected(out iter);
	Feed.FeedItem item = (Feed.FeedItem) ItemList.Model.GetValue(iter, 0);
	View.LoadHtmlString(item.Contents, "");

Interestingly enough, if I remove the code loading the WebView widget with
HTML, the crash disappears.  This initially led me to believe that there was
a problem with WebView, but replacing it with gtk.HTML resulted in the same
problem.  I figure there must be some issue with the why I'm manipulating
the two TreeViews, but I have no idea.  Any help would be greatly
View this message in context: http://www.nabble.com/Crash-when-working-with-multiple-TreeViews-alongside-WebView-tp24445931p24445931.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20090712/56663a43/attachment.html 

More information about the Gtk-sharp-list mailing list