FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Exceptions are not handled from callbacks

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
JNewt



Joined: 05 Jun 2008
Posts: 69

PostPosted: Wed Apr 13, 2011 3:05 pm    Post subject: Exceptions are not handled from callbacks Reply with quote

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
View user's profile Send private message
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Thu Apr 14, 2011 3:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group