title: In Gtk#, why might VALID_ITER fail even after I check it with IterIsValid?
body: <p>I have a convenience function in my <code>TreeView</code> that looks something like this:</p>
  
  <pre><code>Card GetCardFromPath (TreePath path)
  {
      TreeIter iter;
      if (path == null || !Model.GetIter (out iter, path))
          return null;
  
      if ((Model as TreeModelSort).IterIsValid (iter))
          return (Card) Model.GetValue (iter, 0);
  
      return null;
  }
  </code></pre>
  
  <p>Most of the time this works without any errors. But when it is called directly after the Model is changed, line 8 gives me these Gtk runtime errors:</p>
  
  <pre><code>[Fatal 16:53:02.448] [Gtk] gtk_list_store_get_value: assertion `VALID_ITER (iter, list_store)' failed
  [Fatal 16:53:02.449] [GLib-GObject] g_value_unset: assertion `G_IS_VALUE (value)' failed
  </code></pre>
  
  <p>As far as I can tell, I shouldn't even need to check <code>IterIsValid</code>, because I'm already checking the return value of <code>Model.GetIter</code>. Even so, how can <code>VALID_ITER</code> fail in a function that only gets called if <code>IterIsValid</code> returns <code>true</code>?</p>
  
  <p>If it makes a difference, the Model is a <code>TreeModelSort</code>, which sorts a <code>TreeModelFilter</code>, which filters a <code>ListStore</code>. The error occurs when <code>GetCardFromPath</code> is called from <code>HandleSelectionChanged</code> when multiple rows have just been removed from the ListStore. It doesn't seem to prevent anything from working properly, but having a cascade of errors whenever I remove multiple rows isn't really ideal.</p>