Ticket #1236: gtkcrash.hs

File gtkcrash.hs, 1.3 kB (added by guest, 3 years ago)

minimal program to reproduce the crash

Line 
1import Graphics.UI.Gtk
2import Data.Tree
3
4main = do
5  initGUI
6-- adding an initial element to the treeStore will prevent one type of
7-- crash
8--  model <- treeStoreNew [Node "prevent initial crash" []]
9  model <- treeStoreNew [] -- crashes
10  filterModel <- treeModelFilterNew model []
11-- uncommenting this will prevent the crash
12-- however, expanding the row will lead to another
13{-  treeModelFilterSetVisibleFunc filterModel (\iter -> do
14        path <- treeModelGetPath model iter
15        case path of
16          [] -> return False
17          _  -> return True )
18-}
19  treeView <- treeViewNewWithModel filterModel
20  col <- treeViewColumnNew
21  set col [treeViewColumnTitle := "title"]
22  rend <- cellRendererTextNew
23  treeViewColumnPackStart col rend True
24  cellLayoutSetAttributes col rend model $ \row -> [cellText := row]
25  treeViewAppendColumn treeView col
26  button <- buttonNew
27  buttonSetLabel button "crash"
28  on button buttonActivated $ do
29    (treeStoreInsertTree model [] (-1)
30      (Node "expand this for crash" [Node "subnode1" [] , Node "subnode2" []] ))
31  vBox <- vBoxNew False 0
32  boxPackStart vBox treeView PackGrow 0
33  boxPackStart vBox button PackNatural 0
34  window <- windowNew
35  containerAdd window vBox
36  onDestroy window mainQuit
37  windowSetDefaultSize window 300 200
38  widgetShowAll window
39  mainGUI