Hi, We currently just crash and burn when we have trouble with cairo. This doesn't really help the user. The following make sure we output a stack trace and reset the cairo status after a failed drawing operation. Which will hopefully help the user determine how to work around things.
2006-02-18 Mark Wielaard <[EMAIL PROTECTED]>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(begin_drawing_operation): Output stacktrace and return on bad cairo
status.
(end_drawing_operation): Likewise. And reset cairo_t.
Does this seem useful?
Sample output:
java.lang.InternalError: out of memory
at gnu.java.awt.peer.gtk.GdkGraphics2D.cairoFill (Native Method)
at gnu.java.awt.peer.gtk.GdkGraphics2D.fillRect (GdkGraphics2D.java:1076)
at com.jgoodies.plaf.plastic.PlasticUtils.add3DEffekt (PlasticUtils.java:257)
at com.jgoodies.plaf.plastic.PlasticUtils.addLight3DEffekt
(PlasticUtils.java:285)
at com.jgoodies.plaf.plastic.PlasticToolBarUI.update
(PlasticToolBarUI.java:164)
[...]
I don't know the status of the Graphics2D rewrite that Tom was working
on. Maybe that makes this hack unnecessary. If it interferes with that
please yell and scream. I haven't actually found and fixed any real
problems with this patch yet.
Cheers,
Mark
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c,v
retrieving revision 1.36
diff -u -r1.36 gnu_java_awt_peer_gtk_GdkGraphics2D.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c 16 Nov 2005 20:59:12 -0000 1.36
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c 18 Feb 2006 16:17:56 -0000
@@ -1,5 +1,5 @@
/* gnu_java_awt_peer_gtk_GdkGraphics2d.c
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include "jcl.h"
#include "gtkcairopeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkGraphics2D.h"
@@ -261,7 +262,14 @@
static void
begin_drawing_operation (JNIEnv *env, struct graphics2d * gr)
{
- g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
+ cairo_status_t cst = cairo_status (gr->cr);
+ if (cst != CAIRO_STATUS_SUCCESS)
+ {
+ const char *detail = cairo_status_to_string (cst);
+ JCL_ThrowException (env, "java/lang/InternalError", detail);
+ (*env)->ExceptionDescribe (env);
+ return;
+ }
switch (gr->mode)
{
@@ -312,7 +320,19 @@
static void
end_drawing_operation (JNIEnv *env, struct graphics2d * gr)
{
- g_assert(cairo_status (gr->cr) == CAIRO_STATUS_SUCCESS);
+ cairo_status_t cst = cairo_status (gr->cr);
+ if (cst != CAIRO_STATUS_SUCCESS)
+ {
+ /* Report error. */
+ const char *detail = cairo_status_to_string (cst);
+ JCL_ThrowException (env, "java/lang/InternalError", detail);
+ (*env)->ExceptionDescribe (env);
+
+ /* Recreate cairo status. */
+ cairo_destroy (gr->cr);
+ gr->cr = cairo_create (gr->surface);
+ return;
+ }
switch (gr->mode)
{
signature.asc
Description: This is a digitally signed message part
