diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.c b/jdk/src/solaris/native/sun/awt/gtk2_interface.c index 367a9d53025..a26a839d120 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c @@ -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. * * 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; } +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: * http://sourceware.org/bugzilla/show_bug.cgi?id=1814 * (dlsym/dlopen clears dlerror state) @@ -859,14 +869,26 @@ static void init_containers() * comparing results. This can be optimized by using subclassed pixmap and * 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; + GdkPixbuf *white, *black; init_containers(); 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) { /* free old stuff */ (*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); } - gtk2_white_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 = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, - width, height); - gtk2_black_pixbuf = (*fp_gdk_pixbuf_new)(GDK_COLORSPACE_RGB, TRUE, 8, - width, height); + gtk2_white_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_black_pixbuf = black; + gtk2_pixbuf_width = width; gtk2_pixbuf_height = height; } diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.h b/jdk/src/solaris/native/sun/awt/gtk2_interface.h index de09dd82dbd..3ecaf94af20 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.h +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.h @@ -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. * * 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, 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_get_xthickness(JNIEnv *env, WidgetType widget_type); diff --git a/jdk/src/solaris/native/sun/awt/swing_GTKEngine.c b/jdk/src/solaris/native/sun/awt/swing_GTKEngine.c index c579388becb..bcb315cd98d 100644 --- a/jdk/src/solaris/native/sun/awt/swing_GTKEngine.c +++ b/jdk/src/solaris/native/sun/awt/swing_GTKEngine.c @@ -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. * * 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) { fp_gdk_threads_enter(); - gtk2_init_painting(w, h); + gtk2_init_painting(env, w, h); fp_gdk_threads_leave(); }