src/solaris/native/sun/awt/gtk2_interface.c
Print this page
*** 79,89 ****
const gint SELECTED = 1 << 9;
const gint DEFAULT = 1 << 10;
static void *gtk2_libhandle = NULL;
static void *gthread_libhandle = NULL;
! static gboolean flag_g_thread_get_initialized = FALSE;
static jmp_buf j;
/* Widgets */
static GtkWidget *gtk2_widget = NULL;
static GtkWidget *gtk2_window = NULL;
--- 79,89 ----
const gint SELECTED = 1 << 9;
const gint DEFAULT = 1 << 10;
static void *gtk2_libhandle = NULL;
static void *gthread_libhandle = NULL;
!
static jmp_buf j;
/* Widgets */
static GtkWidget *gtk2_widget = NULL;
static GtkWidget *gtk2_window = NULL;
*** 500,510 ****
fp_gtk_file_chooser_get_filenames = dl_symbol(
"gtk_file_chooser_get_filenames");
fp_gtk_g_slist_length = dl_symbol("g_slist_length");
}
! gboolean gtk2_load()
{
gboolean result;
int i;
int (*handler)();
int (*io_handler)();
--- 500,510 ----
fp_gtk_file_chooser_get_filenames = dl_symbol(
"gtk_file_chooser_get_filenames");
fp_gtk_g_slist_length = dl_symbol("g_slist_length");
}
! gboolean gtk2_load(JNIEnv *env)
{
gboolean result;
int i;
int (*handler)();
int (*io_handler)();
*** 808,827 ****
*/
handler = XSetErrorHandler(NULL);
io_handler = XSetIOErrorHandler(NULL);
if (fp_gtk_check_version(2, 2, 0) == NULL) {
! // Init the thread system to use GLib in a thread-safe mode
! if (!flag_g_thread_get_initialized) {
! flag_g_thread_get_initialized = TRUE;
fp_g_thread_init(NULL);
//According the GTK documentation, gdk_threads_init() should be
//called before gtk_init() or gtk_init_check()
fp_gdk_threads_init();
}
}
result = (*fp_gtk_init_check)(NULL, NULL);
XSetErrorHandler(handler);
XSetIOErrorHandler(io_handler);
--- 808,834 ----
*/
handler = XSetErrorHandler(NULL);
io_handler = XSetIOErrorHandler(NULL);
if (fp_gtk_check_version(2, 2, 0) == NULL) {
! jclass class = (*env)->FindClass(env, "sun/misc/GThreadHelper");
! jmethodID mid_isInitializationNeeded = (*env)->GetStaticMethodID(env, class, "isInitializationNeeded", "()Z");
! jmethodID mid_lock = (*env)->GetStaticMethodID(env, class, "lock", "()V");
! jmethodID mid_unlock = (*env)->GetStaticMethodID(env, class, "unlock", "()V");
! jmethodID mid_initFinished = (*env)->GetStaticMethodID(env, class, "initFinished", "()V");
+ // Init the thread system to use GLib in a thread-safe mode
+ (*env)->CallStaticVoidMethod(env, class, mid_lock);
+ if ((*env)->CallStaticBooleanMethod(env, class, mid_isInitializationNeeded)) {
fp_g_thread_init(NULL);
//According the GTK documentation, gdk_threads_init() should be
//called before gtk_init() or gtk_init_check()
fp_gdk_threads_init();
+ (*env)->CallStaticVoidMethod(env, class, mid_initFinished);
}
+ (*env)->CallStaticVoidMethod(env, class, mid_unlock);
}
result = (*fp_gtk_init_check)(NULL, NULL);
XSetErrorHandler(handler);
XSetIOErrorHandler(io_handler);