[Vala] How to initializes the D-BUS thread system ?



A program is multi-threaded and compiled using vala with '--thread' option.

However, the program generated directly by vala will crash soon after it starts.

gdb tells me that the program crashed in dbus_xxxxxx() (randomly)

To resolve this issue, dbus_g_thread_init() or dbus_threads_init_default() should be called.

I use valac to generate C code, than I found all C files have no dbus_g_thread_init(), nor dbus_threads_init_default().

After adding dbus_g_thread_init() or dbus_threads_init_default() in C code and compiling by gcc. The program won't crash again.

So my question is: how to call dbus_g_thread_init() in vala code ? Shouldn't valac do this automatically with '--thread' option ?

I looked dbus-glib-1.vapi, no 'thread' keyword can be found.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]