January 27, 2006

GuarantorTo_be_Killed Toolkit

"GuarantorTo_be_Killed Toolkit" 聽起來頗奇怪,到底是什麼呢?解釋前,先來看看今天早上跟 PCMan 聊天的內容 (in #dot IRC channel):
    07:53:19 pcman : gtk+ tree model 有非常嚴重的 bug
    07:53:31 pcman : 我被迫停止開發了 T_T
    07:53:42 pcman : GtkTreeModelSort 整個根本是壞的
    07:54:07 pcman : 去看 source code 才發現裡面的註解:連開發者自己都不確定那個會不會動
    07:54:29 pcman : 文件裡面竟然沒有警告..... 我在大量使用後發現一堆解決不掉的問題,最後一點辦法都沒有了......
    07:55:15 pcman : 連用奇怪的 workaround 都沒辦法處理....
    07:55:43 pcman : 是可以用 GtkListStore 本身的 GtkTreeSortable interface
    07:55:54 pcman : 只是這樣又不能共用 model
    07:55:54 jserv-- : 真麻煩 XD
    07:56:01 pcman : 每種 sort 要自己一份
    07:56:12 pcman : memory 使用量大增
    07:56:34 * jserv-- 還是用 mc
    07:56:38 pcman : 然後剛剛發現... XFCE Thunar 採用的方案是...自己寫 custom model.... 他根本就不用 gtk+ 的
    07:56:51 pcman : 怒........@_@ 努力了這麼久到剛剛有種上當的感覺
    07:57:16 pcman : 去看 bug report 發現沒人提到,感覺這根本是個大家沒在用的東西
    07:57:50 pcman : 我上次已經偷了 ExoIconView, patch 一下可以用
    07:58:08 pcman : 但這次這個.... 如果用他的我得整個重寫,而且那個沒法共用 child model
    07:58:34 pcman : 那我還不如改用 GtkTreeSortable 然後各 tree view 各 copy 一份 model
    07:58:44 pcman : 這樣應該不會壞
    07:58:51 pcman : 只是很可惜的吃 RAM
    07:59:25 pcman : 但看來是目前唯一可以動的方法.... 沒辦法了,很大一部分得重寫
    07:59:34 jserv-- : !! 07:59:45 pcman : 下次不要用 gtk+ 了
    08:00:23 pcman : 生氣了生氣了.... 被文件耍了半天,debug 好幾天受不了 hack 進去才發現 那根本是爛的 @@
    08:00:46 pcman : 不確定能不能用的東西竟然放在正式版本 release 出來,文件上也沒有警告 = =
    08:01:19 pcman : 這還是 2.8... 一般人使用最多的 2.6 還不知道藏著什麼鬼 bug... 越想越恐怖
    08:01:50 * pcman 開始覺得去 TnLug 講完 gtk+ 簡介後,應該要呼籲大家不要使用.......
    08:02:25 jserv-- : [Orz] pcman 寫 code 被 Gtk+ 耍,難道... GuarantorTo_be_Killed Toolkit ?
    08:03:25 pcman : 這回是真的怒了..... /* WARNING: this code is dangerous, can cause sleepless nights, can cause your dog to die among other bad things. we warned you and we're not liable for any head injuries.
    08:03:52 pcman : 文件上應該把這段寫進去.... 竟然藏在 source code 裡面,害我用得很高興
    08:04:47 jserv-- : 寫 browser 最忌諱這種 unknown behavior :(
    08:05:17 pcman : 最慘的是寫到最後階段,一直有解決不掉的 bug,才發現問題根本來自底層 toolkit......
    08:05:33 pcman : 差一點就寫完了,然後被迫放棄重來 = =
    08:05:59 jserv-- 果然 Gtk+ = GuarantorTo_be_Killed Toolkit
    08:06:30 jserv-- : 找不到擔保人,Nobody cares
    08:06:31 jserv-- : Orz
PCMan 最近的大作是 [PCMan File Manager],而他詬病的部份就是 Gtk+ 的 GtkTreeModelSort,其 source code 可參考 [gtk+/gtk/gtktreemodelsort.c],在一開頭就這麼寫到:
    /* WARNING: this code is dangerous, can cause sleepless nights,
     * can cause your dog to die among other bad things
     *
     * we warned you and we're not liable for any head injuries.
     */
    
這個 "GuarantorTo_be_Killed Toolkit" 真是複雜到不行 :(
由 jserv 發表於 January 27, 2006 03:24 PM
迴響

該檔案內還有另一行非常經典:
/* FIXME: I still have doubts if this works */
static void
gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
GtkTreePath *s_path,
gpointer data)

連開發者自己都不知道可不可以用的東西...
就當作正式版本釋出了,並且文件上沒任何警告

PCMan 發表於 January 27, 2006 08:13 PM

我也碰到类似问题,在google上找到你这里来了。似乎这几个问题gtk+开发者都知道。我在irc.gnome.org #gtk-devel上的聊天记录:

falls hello, I've a question about "GtkTreeModelSort"
falls I found this comment in gtk/gtktreemodelsort.c ( gtk+-2.8.10 ):
falls /* WARNING: this code is dangerous, can cause sleepless nights,
falls * can cause your dog to die among other bad things
falls *
falls * we warned you and we're not liable for any head injuries.
falls */
falls Does it denote that I can't use the functions in this file ?
falls If this file is dangerous , why does it still stay in the gtk+'s stable
falls version ?
kris the comment is just sort of a joke really
falls I've debuged my program for serverl days. At last,I found it's not my fault ,it the bug of "GtkTreeModelSort"
kris (because the code is so hairy/complicated)
falls oh, my god, it's a joke
falls ?
deadchip o_O
kris you might want to try gtk+ HEAD, since some bugs have been fixed in there
kris else file a bug with a good testcase
falls ok, thank u all !
falls In gtk/gtktreemodelsort.c, I found another line :
falls /* FIXME: I still have doubts if this works */
falls static void
falls gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
kris that one has been removed in gtk+ HEA DIIRC
falls oh , I see .
kris s/HEA DIIRC/HEAD IIRC/

falls 發表於 February 4, 2006 09:28 AM
發表迴響









記住我的資訊?