# HG changeset patch # User Jordan Miner # Date 1249779633 18000 # Node ID cf7c5f968306ad9699de5bd0096a12276472de5f # Parent d3ba5d4a3a27444f1225830dead25d61ffc790f6 Fix crash in withGraphics() if there wasn't a Window ancestor with a handle. diff -r d3ba5d4a3a27 -r cf7c5f968306 dynamin/gui/control.d --- 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; }); +}