From 9084a3304facd168181a21654a13cb1118a49ad2 Mon Sep 17 00:00:00 2001
From: Lars Kanis <kanis@comcard.de>
Date: Tue, 7 Jul 2015 08:41:05 +0200
Subject: [PATCH] Release ressources for interrupt handling.

---
 ext/fox16_c/FXRbApp.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ext/fox16_c/FXRbApp.cpp b/ext/fox16_c/FXRbApp.cpp
index 5968ad3..cd79ea1 100644
--- a/ext/fox16_c/FXRbApp.cpp
+++ b/ext/fox16_c/FXRbApp.cpp
@@ -94,7 +94,18 @@ void FXRbApp::setThreadsEnabled(FXbool enabled){
     }
   else{
     m_bThreadsEnabled=FALSE;
+#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
+#ifdef WIN32
+    removeInput(interrupt_event,INPUT_READ);
+    CloseHandle(interrupt_event); interrupt_event = NULL;
+#else
+    removeInput(interrupt_fds[0],INPUT_READ);
+    close(interrupt_fds[0]); interrupt_fds[0] = -1;
+    close(interrupt_fds[1]); interrupt_fds[1] = -1;
+#endif
+#else
     removeChore(this,ID_CHORE_THREADS);
+#endif
     }
   }
 
@@ -168,6 +179,7 @@ void fxrb_wakeup_fox(void *){
 FXRbApp::~FXRbApp(){
   FXTRACE((100,"FXRbApp::~FXRbApp()\n"));
   VALUE myRegistry;
+  setThreadsEnabled(FALSE);
   FXRbDestroyAppSensitiveObjects();
   myRegistry=FXRbGetRubyObj(&(reg()),true);
   if(!NIL_P(myRegistry)){
-- 
GitLab