6741392: libmawt.so crash at Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting+0x4f
Reviewed-by: peterz
This commit is contained in:
parent
817fbc9a0b
commit
575b9e1d81
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -371,6 +371,16 @@ const char *getStrFor(JNIEnv *env, jstring val)
|
|||||||
return convertionBuffer;
|
return convertionBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void throw_exception(JNIEnv *env, const char* name, const char* message)
|
||||||
|
{
|
||||||
|
jclass class = (*env)->FindClass(env, name);
|
||||||
|
|
||||||
|
if (class != NULL)
|
||||||
|
(*env)->ThrowNew(env, class, message);
|
||||||
|
|
||||||
|
(*env)->DeleteLocalRef(env, class);
|
||||||
|
}
|
||||||
|
|
||||||
/* This is a workaround for the bug:
|
/* This is a workaround for the bug:
|
||||||
* http://sourceware.org/bugzilla/show_bug.cgi?id=1814
|
* http://sourceware.org/bugzilla/show_bug.cgi?id=1814
|
||||||
* (dlsym/dlopen clears dlerror state)
|
* (dlsym/dlopen clears dlerror state)
|
||||||
@ -859,14 +869,26 @@ static void init_containers()
|
|||||||
* comparing results. This can be optimized by using subclassed pixmap and
|
* comparing results. This can be optimized by using subclassed pixmap and
|
||||||
* doing the second drawing only if necessary.
|
* doing the second drawing only if necessary.
|
||||||
*/
|
*/
|
||||||
void gtk2_init_painting(gint width, gint height)
|
void gtk2_init_painting(JNIEnv *env, gint width, gint height)
|
||||||
{
|
{
|
||||||
GdkGC *gc;
|
GdkGC *gc;
|
||||||
|
GdkPixbuf *white, *black;
|
||||||
|
|
||||||
init_containers();
|
init_containers();
|
||||||
|
|
||||||
if (gtk2_pixbuf_width < width || gtk2_pixbuf_height < height)
|
if (gtk2_pixbuf_width < width || gtk2_pixbuf_height < height)
|
||||||
{
|
{
|
||||||
|
white = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
|
||||||
|
black = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
|
||||||
|
|
||||||
|
if (white == NULL || black == NULL)
|
||||||
|
{
|
||||||
|
snprintf(convertionBuffer, CONV_BUFFER_SIZE, "Couldn't create pixbuf of size %dx%d", width, height);
|
||||||
|
throw_exception(env, "java/lang/RuntimeException", convertionBuffer);
|
||||||
|
fp_gdk_threads_leave();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gtk2_white_pixmap != NULL) {
|
if (gtk2_white_pixmap != NULL) {
|
||||||
/* free old stuff */
|
/* free old stuff */
|
||||||
(*fp_g_object_unref)(gtk2_white_pixmap);
|
(*fp_g_object_unref)(gtk2_white_pixmap);
|
||||||
@ -875,14 +897,12 @@ void gtk2_init_painting(gint width, gint height)
|
|||||||
(*fp_g_object_unref)(gtk2_black_pixbuf);
|
(*fp_g_object_unref)(gtk2_black_pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk2_white_pixmap = (*fp_gdk_pixmap_new)
|
gtk2_white_pixmap = (*fp_gdk_pixmap_new)(gtk2_window->window, width, height, -1);
|
||||||
(gtk2_window->window, width, height, -1);
|
gtk2_black_pixmap = (*fp_gdk_pixmap_new)(gtk2_window->window, width, height, -1);
|
||||||
gtk2_black_pixmap = (*fp_gdk_pixmap_new)
|
|
||||||
(gtk2_window->window, width, height, -1);
|
gtk2_white_pixbuf = white;
|
||||||
gtk2_white_pixbuf = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8,
|
gtk2_black_pixbuf = black;
|
||||||
width, height);
|
|
||||||
gtk2_black_pixbuf = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8,
|
|
||||||
width, height);
|
|
||||||
gtk2_pixbuf_width = width;
|
gtk2_pixbuf_width = width;
|
||||||
gtk2_pixbuf_height = height;
|
gtk2_pixbuf_height = height;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -717,7 +717,7 @@ void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
|
|||||||
void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
|
void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
|
||||||
gint x, gint y, gint width, gint height);
|
gint x, gint y, gint width, gint height);
|
||||||
|
|
||||||
void gtk2_init_painting(gint w, gint h);
|
void gtk2_init_painting(JNIEnv *env, gint w, gint h);
|
||||||
gint gtk2_copy_image(gint *dest, gint width, gint height);
|
gint gtk2_copy_image(gint *dest, gint width, gint height);
|
||||||
|
|
||||||
gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
|
gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -293,7 +293,7 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting(
|
|||||||
JNIEnv *env, jobject this, jint w, jint h)
|
JNIEnv *env, jobject this, jint w, jint h)
|
||||||
{
|
{
|
||||||
fp_gdk_threads_enter();
|
fp_gdk_threads_enter();
|
||||||
gtk2_init_painting(w, h);
|
gtk2_init_painting(env, w, h);
|
||||||
fp_gdk_threads_leave();
|
fp_gdk_threads_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user