Thread: [Java-gnome-developer] Assertion failure while drawing on DrawingArea
Brought to you by:
afcowie
From: Jaime <re...@sa...> - 2004-12-12 14:09:58
|
Hi folks. I've tried to write a simple little program to draw on a DrawingArea, but without success. I get the following assertion failure at runtime: (java-gnome:2393): Gdk-CRITICAL **: file gdkdraw.c: line 338 (gdk_draw_point): assertion `GDK_IS_DRAWABLE (drawable)' failed Could anyone please tell me where I'm going wrong? In fact, a pointer to any example code which successfully draws onto a DrawingArea would be just as good! Thank you, Jaime :-) <snip> package drawingAreaTest; import org.gnu.gtk.DrawingArea; import org.gnu.gtk.Gtk; import org.gnu.gtk.Window; import org.gnu.gtk.WindowType; import org.gnu.gtk.event.ExposeEvent; import org.gnu.gtk.event.ExposeListener; import org.gnu.gtk.event.LifeCycleEvent; import org.gnu.gtk.event.LifeCycleListener; public class Test { DrawingArea area = null; Window window; Test() { window = new Window(WindowType.TOPLEVEL); window.setTitle("Drawing Area Example"); window.addListener(new LifeCycleListener() { public void lifeCycleEvent(LifeCycleEvent event) { } public boolean lifeCycleQuery(LifeCycleEvent event) { if (event.isOfType(LifeCycleEvent.Type.DESTROY) || event.isOfType(LifeCycleEvent.Type.DELETE)) { Gtk.mainQuit(); } return true; } }); area=new DrawingArea(); window.add(area); area.addListener(new ExposeListener() { public boolean exposeEvent(ExposeEvent event) { System.out.println("Expose event: "+window.getWindow()); window.getWindow().drawPoint(20, 20); return false; } }); window.showAll(); System.out.println("Should be printed before expose event"); } public static void main(String[] args) { Gtk.init(args); new Test(); Gtk.main(); } } </snip> |
From: Jeff M. <ku...@gm...> - 2004-12-12 14:53:36
|
What version of java-gnome are you using? Are you using cvs HEAD? On Sun, 12 Dec 2004 14:08:57 +0000, Jaime <re...@sa...> wrote: > Hi folks. > > I've tried to write a simple little program to draw on a DrawingArea, > but without success. I get the following assertion failure at runtime: > > (java-gnome:2393): Gdk-CRITICAL **: file gdkdraw.c: line 338 > (gdk_draw_point): assertion `GDK_IS_DRAWABLE (drawable)' failed > > Could anyone please tell me where I'm going wrong? In fact, a pointer to > any example code which successfully draws onto a DrawingArea would be > just as good! Thank you, > > Jaime :-) > > <snip> > package drawingAreaTest; > > import org.gnu.gtk.DrawingArea; > import org.gnu.gtk.Gtk; > import org.gnu.gtk.Window; > import org.gnu.gtk.WindowType; > import org.gnu.gtk.event.ExposeEvent; > import org.gnu.gtk.event.ExposeListener; > import org.gnu.gtk.event.LifeCycleEvent; > import org.gnu.gtk.event.LifeCycleListener; > > public class Test { > > DrawingArea area = null; > > Window window; > > Test() { > window = new Window(WindowType.TOPLEVEL); > window.setTitle("Drawing Area Example"); > window.addListener(new LifeCycleListener() { > public void lifeCycleEvent(LifeCycleEvent event) { > } > public boolean lifeCycleQuery(LifeCycleEvent event) { > if (event.isOfType(LifeCycleEvent.Type.DESTROY) > || event.isOfType(LifeCycleEvent.Type.DELETE)) { > Gtk.mainQuit(); > } > return true; > } > }); > area=new DrawingArea(); > window.add(area); > area.addListener(new ExposeListener() { > public boolean exposeEvent(ExposeEvent event) { > System.out.println("Expose event: "+window.getWindow()); > window.getWindow().drawPoint(20, 20); > return false; > } > }); > window.showAll(); > System.out.println("Should be printed before expose event"); > } > > public static void main(String[] args) { > Gtk.init(args); > new Test(); > Gtk.main(); > } > > } > </snip> > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > -- Jeffrey Morgan "The highest reward for a man's toil is not what he gets for it, but what he becomes by it" - Jon Ruskin |
From: Jaime <re...@sa...> - 2004-12-12 15:10:50
|
On Sun, 2004-12-12 at 09:53 -0500, Jeff Morgan wrote: > What version of java-gnome are you using? Are you using > cvs HEAD? > > Sorry Jeff, I should have mentioned in my original email that I'm using the latest stable releases available from ftp.gnome.org i.e. libgtk-java: 2.4.6 libgnome-java: 2.8.2 libglade-java: 2.8.2 libgconf-java: 2.8.2 Do you know whether this is something that's been "fixed" in cvs (if so, I'll download cvs and try to compile it) Thanks, Jaime > On Sun, 12 Dec 2004 14:08:57 +0000, Jaime <re...@sa...> wrote: > > Hi folks. > > > > I've tried to write a simple little program to draw on a DrawingArea, > > but without success. I get the following assertion failure at runtime: > > > > (java-gnome:2393): Gdk-CRITICAL **: file gdkdraw.c: line 338 > > (gdk_draw_point): assertion `GDK_IS_DRAWABLE (drawable)' failed > > > > Could anyone please tell me where I'm going wrong? In fact, a pointer to > > any example code which successfully draws onto a DrawingArea would be > > just as good! Thank you, > > > > Jaime :-) > > > > <snip> > > package drawingAreaTest; > > > > import org.gnu.gtk.DrawingArea; > > import org.gnu.gtk.Gtk; > > import org.gnu.gtk.Window; > > import org.gnu.gtk.WindowType; > > import org.gnu.gtk.event.ExposeEvent; > > import org.gnu.gtk.event.ExposeListener; > > import org.gnu.gtk.event.LifeCycleEvent; > > import org.gnu.gtk.event.LifeCycleListener; > > > > public class Test { > > > > DrawingArea area = null; > > > > Window window; > > > > Test() { > > window = new Window(WindowType.TOPLEVEL); > > window.setTitle("Drawing Area Example"); > > window.addListener(new LifeCycleListener() { > > public void lifeCycleEvent(LifeCycleEvent event) { > > } > > public boolean lifeCycleQuery(LifeCycleEvent event) { > > if (event.isOfType(LifeCycleEvent.Type.DESTROY) > > || event.isOfType(LifeCycleEvent.Type.DELETE)) { > > Gtk.mainQuit(); > > } > > return true; > > } > > }); > > area=new DrawingArea(); > > window.add(area); > > area.addListener(new ExposeListener() { > > public boolean exposeEvent(ExposeEvent event) { > > System.out.println("Expose event: "+window.getWindow()); > > window.getWindow().drawPoint(20, 20); > > return false; > > } > > }); > > window.showAll(); > > System.out.println("Should be printed before expose event"); > > } > > > > public static void main(String[] args) { > > Gtk.init(args); > > new Test(); > > Gtk.main(); > > } > > > > } > > </snip> > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://productguide.itmanagersjournal.com/ > > _______________________________________________ > > java-gnome-developer mailing list > > jav...@li... > > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > > > > |
From: Jeff M. <ku...@gm...> - 2004-12-12 15:17:02
|
I have no reason to believe that it is fixed in cvs but there have been numerous changes in cvs. In fact, cvs is currently quite unstable. We are in the process of adding support for 64-bit platforms. Anyway, I will take a look at your example and see if I can find the bug in java-gnome. On Sun, 12 Dec 2004 15:10:40 +0000, Jaime <re...@sa...> wrote: > On Sun, 2004-12-12 at 09:53 -0500, Jeff Morgan wrote: > > What version of java-gnome are you using? Are you using > > cvs HEAD? > > > > > > Sorry Jeff, I should have mentioned in my original email that I'm using > the latest stable releases available from ftp.gnome.org i.e. > libgtk-java: 2.4.6 > libgnome-java: 2.8.2 > libglade-java: 2.8.2 > libgconf-java: 2.8.2 > > Do you know whether this is something that's been "fixed" in cvs (if so, > I'll download cvs and try to compile it) > > Thanks, Jaime > > > > > On Sun, 12 Dec 2004 14:08:57 +0000, Jaime <re...@sa...> wrote: > > > Hi folks. > > > > > > I've tried to write a simple little program to draw on a DrawingArea, > > > but without success. I get the following assertion failure at runtime: > > > > > > (java-gnome:2393): Gdk-CRITICAL **: file gdkdraw.c: line 338 > > > (gdk_draw_point): assertion `GDK_IS_DRAWABLE (drawable)' failed > > > > > > Could anyone please tell me where I'm going wrong? In fact, a pointer to > > > any example code which successfully draws onto a DrawingArea would be > > > just as good! Thank you, > > > > > > Jaime :-) > > > > > > <snip> > > > package drawingAreaTest; > > > > > > import org.gnu.gtk.DrawingArea; > > > import org.gnu.gtk.Gtk; > > > import org.gnu.gtk.Window; > > > import org.gnu.gtk.WindowType; > > > import org.gnu.gtk.event.ExposeEvent; > > > import org.gnu.gtk.event.ExposeListener; > > > import org.gnu.gtk.event.LifeCycleEvent; > > > import org.gnu.gtk.event.LifeCycleListener; > > > > > > public class Test { > > > > > > DrawingArea area = null; > > > > > > Window window; > > > > > > Test() { > > > window = new Window(WindowType.TOPLEVEL); > > > window.setTitle("Drawing Area Example"); > > > window.addListener(new LifeCycleListener() { > > > public void lifeCycleEvent(LifeCycleEvent event) { > > > } > > > public boolean lifeCycleQuery(LifeCycleEvent event) { > > > if (event.isOfType(LifeCycleEvent.Type.DESTROY) > > > || event.isOfType(LifeCycleEvent.Type.DELETE)) { > > > Gtk.mainQuit(); > > > } > > > return true; > > > } > > > }); > > > area=new DrawingArea(); > > > window.add(area); > > > area.addListener(new ExposeListener() { > > > public boolean exposeEvent(ExposeEvent event) { > > > System.out.println("Expose event: "+window.getWindow()); > > > window.getWindow().drawPoint(20, 20); > > > return false; > > > } > > > }); > > > window.showAll(); > > > System.out.println("Should be printed before expose event"); > > > } > > > > > > public static void main(String[] args) { > > > Gtk.init(args); > > > new Test(); > > > Gtk.main(); > > > } > > > > > > } > > > </snip> > > > > > > ------------------------------------------------------- > > > SF email is sponsored by - The IT Product Guide > > > Read honest & candid reviews on hundreds of IT Products from real users. > > > Discover which products truly live up to the hype. Start reading now. > > > http://productguide.itmanagersjournal.com/ > > > _______________________________________________ > > > java-gnome-developer mailing list > > > jav...@li... > > > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > > > > > > > > > > ------------------------------------------------------- > > > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > -- Jeffrey Morgan "The highest reward for a man's toil is not what he gets for it, but what he becomes by it" - Jon Ruskin |
From: Mark H. <mh...@ti...> - 2004-12-12 16:55:24
|
Hi, I'm not familiar with the drawing widgets, so this is completely off the top of my head: You've created a window and filled it with a DrawingArea. You try to draw on the window, but this fails. I'm guessing that this fails since there is already something else on the window -- the DrawingArea. Try changing your code to DrawPoint on the drawingarea instead. Please write back saying if it works or not. -- .''`. Mark Howard : :' : `. `' http://www.tildemh.com `- mh...@de... | mh...@ti... |
From: Jaime <re...@sa...> - 2004-12-12 19:40:38
|
On Sun, 2004-12-12 at 16:55 +0000, Mark Howard wrote: > Hi, > > I'm not familiar with the drawing widgets, so this is completely off the top of > my head: > > You've created a window and filled it with a DrawingArea. > You try to draw on the window, but this fails. I'm guessing that this fails > since there is already something else on the window -- the DrawingArea. > > Try changing your code to DrawPoint on the drawingarea instead. Please write > back saying if it works or not. > Hi Mark. Unfortunately, neither the "top level window" (of type org.gnu.gtk.Window) nor the DrawingArea embedded inside it (of type org.gnu.gtk.DrawingArea) possess a drawPoint() method - the only class which does (according to the javadocs) is an "org.gnu.gdk.Window" (notice the change from gtk.Window to gdk.Window!) This itself, is fine, as it seems to agree with the following documentation: a) The javadocs for org.gnu.gtk.Widget.getWindow() ("Return the widget's gdk window. This is the window to draw upon when writing custom widgets. It's available after the widget has been mapped. Thus if you listen to LifeCycleEvents, you can fetch the Window instance using this method after an LifeCycleEvent of type MAP has occured. Returns: the widget's gdk window, or null if a) it hasn't been mapped yet or b) it is of a type that doesn't have a gdk window. b) http://www.pygtk.org/pygtk2tutorial/sec-DrawingMethods.html The example code "drawingarea.py" is what I'm actually trying to port to java - line 41, for example, refers to: self.area.window.draw_point(self.gc, x+30, y+30) ("area" is the drawing area, the "window" attribute is its embedded gdkWindow, which gets drawn upon using the "draw_point" method) c) http://developer.gnome.org/doc/API/2.0/gtk/GtkDrawingArea.html and http://www.gtk.org/tutorial/sec-thedrawingareawidget.html Incidently, I've tried using both the gdk.Window returned by both area.getWindow() _and_ window.getWindow(), but they both return the same error. Hope some of this makes sense, Jaime :-) |
From: Jeff M. <ku...@gm...> - 2005-01-06 01:21:28
|
I do have some good news for you. There have been many bugs fixed in the latest cvs. I just ran your example and it works without the crash. In fact, it is now in our cvs. If you are runing the HEAD you should be able to create your DrawingArea now. If you are using anonymous cvs you may have to wait until tomorrow for all of the fixes to appear. On Sun, 12 Dec 2004 19:40:24 +0000, Jaime <re...@sa...> wrote: > On Sun, 2004-12-12 at 16:55 +0000, Mark Howard wrote: > > Hi, > > > > I'm not familiar with the drawing widgets, so this is completely off the top of > > my head: > > > > You've created a window and filled it with a DrawingArea. > > You try to draw on the window, but this fails. I'm guessing that this fails > > since there is already something else on the window -- the DrawingArea. > > > > Try changing your code to DrawPoint on the drawingarea instead. Please write > > back saying if it works or not. > > > Hi Mark. > > Unfortunately, neither the "top level window" (of type > org.gnu.gtk.Window) nor the DrawingArea embedded inside it (of type > org.gnu.gtk.DrawingArea) possess a drawPoint() method - the only class > which does (according to the javadocs) is an > "org.gnu.gdk.Window" (notice the change from gtk.Window to gdk.Window!) > > This itself, is fine, as it seems to agree with the following > documentation: > > a) The javadocs for org.gnu.gtk.Widget.getWindow() ("Return the widget's > gdk window. This is the window to draw upon when writing custom widgets. > It's available after the widget has been mapped. Thus if you listen to > LifeCycleEvents, you can fetch the Window instance using this method > after an LifeCycleEvent of type MAP has occured. Returns: the widget's > gdk window, or null if a) it hasn't been mapped yet or b) it is of a > type that doesn't have a gdk window. > > b) http://www.pygtk.org/pygtk2tutorial/sec-DrawingMethods.html > The example code "drawingarea.py" is what I'm actually trying to port to > java - line 41, for example, refers to: > self.area.window.draw_point(self.gc, x+30, y+30) > ("area" is the drawing area, the "window" attribute is its embedded > gdkWindow, which gets drawn upon using the "draw_point" method) > > c) http://developer.gnome.org/doc/API/2.0/gtk/GtkDrawingArea.html > and http://www.gtk.org/tutorial/sec-thedrawingareawidget.html > > Incidently, I've tried using both the gdk.Window returned by both > area.getWindow() _and_ window.getWindow(), but they both return the same > error. > > Hope some of this makes sense, > > Jaime :-) > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > -- Jeffrey Morgan "The highest reward for a man's toil is not what he gets for it, but what he becomes by it" - Jon Ruskin |