Clutter 不支持多线程

看这个简单的例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <clutter/clutter.h>
 
static gpointer
gen_slide (gpointer data)
{
        return clutter_cairo_texture_new (800.0, 600.0);
}
 
static gboolean
on_stage_button_press (ClutterActor *stage, ClutterEvent *event, gpointer data)
{
        g_thread_new ("test", gen_slide, NULL);
        return TRUE;
}
 
int
main(int argc, char *argv[])
{
        if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
                return 1;
 
        ClutterColor stage_color = { 0x21, 0x43, 0x5e, 0xff };
        ClutterActor *stage = clutter_stage_get_default ();
        clutter_stage_set_title (CLUTTER_STAGE (stage), "CairoTexture!");
        clutter_actor_set_size (stage, 400, 400);
        clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
        clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
 
        clutter_actor_show_all (stage);
 
        g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
        g_signal_connect (stage, "button-press-event", G_CALLBACK (on_stage_button_press), NULL);
         
        clutter_main ();
            
        return 0;
}

编译它:

1
gcc `pkg-config --cflags --libs clutter-1.0` test.c

这个程序需要 >=glib-2.32 版本的支持。运行程序时,鼠标点一下窗口内部区域,在我这里程序便会崩溃。不知是不是只有我遇到这个问题。

这样子,Cikada 就没法实现单独加载 pdf 页面的线程了。