Skip to content
Browse files

add SignalHandler for SIGINT. close #15

  • Loading branch information...
1 parent 3a5d1d2 commit 35b371c0d1e04c6af0306fcff4602ebb8ac0d518 @Hanmac committed Jun 2, 2016
Showing with 10 additions and 0 deletions.
  1. +10 −0 ext/wxApp.cpp
View
10 ext/wxApp.cpp
@@ -57,6 +57,11 @@ void app_protected()
}
+void rwx_sigint(int)
+{
+ wxExit();
+}
+
RubyApp::RubyApp(VALUE klass)
{
mRuby = wrapTypedPtr(this,klass);
@@ -74,6 +79,7 @@ bool RubyApp::OnInit()
SetFrontProcess( &psn );
#endif
+
RubyWX::Color::define_const();
RubyWX::Font::define_const();
RubyWX::Brush::define_const();
@@ -94,6 +100,10 @@ bool RubyApp::OnInit()
this->Bind(wxEVT_ASYNC_METHOD_CALL,AppAfter());
ruby_app_inited = true;
+ // binds SIGINT to wxExit to close the application
+#if defined(__UNIX__) && !defined(__WINDOWS__)
+ SetSignalHandler(wxSIGINT, rwx_sigint);
+#endif
bool result = RTEST(rb_funcall(mRuby, rb_intern("on_init"), 0));
if(rb_block_given_p())

0 comments on commit 35b371c

Please sign in to comment.
Something went wrong with that request. Please try again.