From: Robert M. <ro...@mi...> - 2006-12-07 06:27:15
|
On Wed, 2006-12-06 at 10:55 +0000, Axel Simon wrote: > > ListStoreNew.customModelGetIter should check if 'n' is in bounds before > > returning an iter. If so, I can provide a patch. > > This, on the other hand, is probably superfluous. Turning an index into > an iter is only performed by a view once it has established that the nth > element exists. Even if it creates and uses an invalid iterator, the > fault is caught in customTreeModelGetRow when accessing the entry. treeModelGetIter seems to be built upon this function (in gtk+ itself) and seems to be returning invalid iters for empty ListStoreNews. Likewise for treeModelGetIterFirst which is built on it: import Graphics.UI.Gtk import qualified Graphics.UI.Gtk.TreeList.ListStoreNew as LS main :: IO () main = do initGUI store <- LS.listStoreNew ([] :: [String]) first <- treeModelGetIterFirst store third <- treeModelGetIter store [2] putStrLn $ "First: " ++ (show first) ++ "; Third: " ++ (show third) x <- maybe (return Nothing) (\x -> Just `fmap` treeModelGetValue store x 0) first return () Outputs: First: Just (TreeIter (-374412069) 0 0 0); Third: Just (TreeIter (-374412069) 2 0 0) (Test2:8164): GLib-GObject-WARNING **: gtype.c:3337: type id `0' is invalid (Test2:8164): GLib-GObject-WARNING **: can't peek value table for type `<invalid>' which is not currently referenced (Test2:8164): GLib-GObject-WARNING **: gvalue.c:96: cannot initialize GValue with type `(null)', this type has no GTypeValueTable implementation Test2: StoreValue.valueGetGenericValue: invalid or unavailable value. -- Robert Marlow MITS Co-operative Limited http://www.mits.coop/ |