changeset 60:cf7c5f968306

Fix crash in withGraphics() if there wasn't a Window ancestor with a handle.
author Jordan Miner <jminer7@gmail.com>
date Sat, 08 Aug 2009 20:00:33 -0500
parents d3ba5d4a3a27
children f8f5d6244795
files dynamin/gui/control.d
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dynamin/gui/control.d	Sat Aug 08 18:02:43 2009 -0500
+++ b/dynamin/gui/control.d	Sat Aug 08 20:00:33 2009 -0500
@@ -286,7 +286,8 @@
 		if(_parent is null)
 			return null;
 		auto g = _parent.quickCreateGraphics();
-		g.translate(location);
+		if(g)
+			g.translate(location);
 		return g;
 	}
 
@@ -307,6 +308,8 @@
 	 */
 	void withGraphics(void delegate(Graphics g) dg) {
 		auto g = quickCreateGraphics();
+		if(!g)
+			return;
 		setupGraphics(g);
 		dg(g);
 		delete g;
@@ -674,4 +677,8 @@
 	}
 }
 
+unittest {
+	Control c = new Control;
+	c.withGraphics((Graphics g) { g.source = Color.Blue; });
+}