View previous topic :: View next topic |
Author |
Message |
JNewt
Joined: 05 Jun 2008 Posts: 69
|
Posted: Wed Apr 13, 2011 3:05 pm Post subject: Exceptions are not handled from callbacks |
|
|
Using the latest gtkD revision (824), I've built a slightly modified version of the "Exit Button" example:
Code: |
import gtk.MainWindow;
import gtk.Button;
import gtk.Main;
import std.stdio; // added this
class ExitButton : MainWindow
{
this()
{
super("Exit Button");
setDefaultSize(50, 30);
Button exitbtn = new Button();
exitbtn.setLabel("Exit");
exitbtn.addOnClicked(&exitProg);
add(exitbtn);
showAll();
}
void exitProg(Button button)
{
throw new Exception("Bam!"); // added this line
writeln("Shouldn't get here"); // and this one
Main.exit(0);
}
}
void main(string[] args)
{
Main.init(args);
new ExitButton();
Main.run();
} |
Built with dmd 2.052 and -m64, I get the following output:
Code: |
dmd testcase.d -m64 -I../gtkd/trunk/src/ -L../gtkd/trunk/libgtkd.a -L-ldl
Shouldn't get here |
As you can see, the exception in the callback function is not being handled at the top level. Surrounding the throw with a try catch demonstrates that the exception is being thrown--so either it's not propagating all the way up or gtkD's Main.run is catching it silently. Can anyone explain what's going on and how to change this behavior? |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Thu Apr 14, 2011 3:14 pm Post subject: |
|
|
With dmd 2.052 i get the following output:
Code: | object.Exception@button.d(21): Bam!
stacktrace.... |
But thats with a 32bits binary, since i'm on a 32bits machine.
Quote: | so either it's not propagating all the way up or gtkD's Main.run is catching it silently. Can anyone explain what's going on and how to change this behavior? |
Even if gtkD would catch and handle the exception it still shouldn't print: "Shouldn't get here"
[/code] |
|
Back to top |
|
|
|