changeset 1861:c836603d3f14

Add dw_shutdown() function which does the same thing as dw_exit() ... except it doesn't actually end the process. Useful for bindings that are expecting to do their own cleanup after the script exits.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 01 Mar 2013 16:51:08 +0000
parents 02a23143334c
children 9c7485b1921c
files dw.h gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c os2/dw.def os2/dw.lnk win/dw-mingw.def win/dw.c win/dw.def
diffstat 10 files changed, 66 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Fri Mar 01 13:01:59 2013 +0000
+++ b/dw.h	Fri Mar 01 16:51:08 2013 +0000
@@ -1679,6 +1679,7 @@
 void API dw_thread_end(void);
 DWTID API dw_thread_id(void);
 void API dw_exit(int exitcode);
+void API dw_shutdown(void);
 HWND API dw_render_new(unsigned long id);
 void API dw_color_foreground_set(unsigned long value);
 void API dw_color_background_set(unsigned long value);
--- a/gtk/dw.c	Fri Mar 01 13:01:59 2013 +0000
+++ b/gtk/dw.c	Fri Mar 01 16:51:08 2013 +0000
@@ -10157,15 +10157,24 @@
 
 /*
  * Cleanly terminates a DW session, should be signal handler safe.
+ */
+void dw_shutdown(void)
+{
+   if ( dbgfp != NULL )
+   {
+      fclose( dbgfp );
+      dbgfp = NULL;
+   }
+}
+
+/*
+ * Cleanly terminates a DW session, should be signal handler safe.
  * Parameters:
  *       exitcode: Exit code reported to the operating system.
  */
 void dw_exit(int exitcode)
 {
-   if ( dbgfp != NULL )
-   {
-      fclose( dbgfp );
-   }
+   dw_shutdown();
    exit(exitcode);
 }
 
--- a/gtk3/dw.c	Fri Mar 01 13:01:59 2013 +0000
+++ b/gtk3/dw.c	Fri Mar 01 16:51:08 2013 +0000
@@ -8396,6 +8396,13 @@
 
 /*
  * Cleanly terminates a DW session, should be signal handler safe.
+ */
+void dw_shutdown(void)
+{
+}
+
+/*
+ * Cleanly terminates a DW session, should be signal handler safe.
  * Parameters:
  *       exitcode: Exit code reported to the operating system.
  */
--- a/mac/dw.m	Fri Mar 01 13:01:59 2013 +0000
+++ b/mac/dw.m	Fri Mar 01 16:51:08 2013 +0000
@@ -3216,15 +3216,23 @@
 
 /*
  * Cleanly terminates a DW session, should be signal handler safe.
- * Parameters:
- *       exitcode: Exit code reported to the operating system.
- */
-void API dw_exit(int exitcode)
+ */
+void API dw_shutdown(void)
 {
 #if !defined(GARBAGE_COLLECT)
     pool = pthread_getspecific(_dw_pool_key);
     [pool drain];
 #endif
+}
+
+/*
+ * Cleanly terminates a DW session, should be signal handler safe.
+ * Parameters:
+ *       exitcode: Exit code reported to the operating system.
+ */
+void API dw_exit(int exitcode)
+{
+    dw_shutdown();
     exit(exitcode);
 }
 
@@ -8299,7 +8307,8 @@
     [window setDelegate:view];
     [window setAutorecalculatesKeyViewLoop:YES];
     [window setAcceptsMouseMovedEvents:YES];
-    [view release];
+    [window setReleasedWhenClosed:YES];
+    [view autorelease];
 
     /* Enable full screen mode on resizeable windows */
     if(flStyle & DW_FCF_SIZEBORDER)
--- a/os2/dw.c	Fri Mar 01 13:01:59 2013 +0000
+++ b/os2/dw.c	Fri Mar 01 16:51:08 2013 +0000
@@ -11836,10 +11836,8 @@
 
 /*
  * Cleanly terminates a DW session, should be signal handler safe.
- * Parameters:
- *       exitcode: Exit code reported to the operating system.
- */
-void API dw_exit(int exitcode)
+ */
+void API dw_shutdown(void)
 {
    /* Destroy the menu message window */
    dw_window_destroy(hwndApp);
@@ -11852,7 +11850,10 @@
 
    /* Deinit the GBM */
    if(_gbm_deinit)
+   {
        _gbm_deinit();
+       _gbm_deinit = NULL;
+   }
 
 #ifdef UNICODE
    /* Free the conversion object */
@@ -11870,7 +11871,16 @@
    DosFreeModule(pmprintf);
    DosFreeModule(pmmerge);
    DosFreeModule(gbm);
-   
+}
+
+/*
+ * Cleanly terminates a DW session, should be signal handler safe.
+ * Parameters:
+ *       exitcode: Exit code reported to the operating system.
+ */
+void API dw_exit(int exitcode)
+{
+   dw_shutdown();
    /* And finally exit */
    exit(exitcode);
 }
--- a/os2/dw.def	Fri Mar 01 13:01:59 2013 +0000
+++ b/os2/dw.def	Fri Mar 01 16:51:08 2013 +0000
@@ -12,7 +12,6 @@
   dw_beep                                @13
   dw_messagebox                          @14
   dw_debug                               @15
-
   dw_environment_query                   @16
   dw_exec                                @17
   dw_browse                              @18
@@ -24,6 +23,7 @@
   dw_main_iteration                      @24
   dw_app_dir                             @25
   dw_main_quit                           @26
+  dw_shutdown                            @27
 
   dw_box_new                             @40
   dw_groupbox_new                        @41
--- a/os2/dw.lnk	Fri Mar 01 13:01:59 2013 +0000
+++ b/os2/dw.lnk	Fri Mar 01 16:51:08 2013 +0000
@@ -7,7 +7,6 @@
 export dw_beep.13
 export dw_messagebox.14
 export dw_debug.15
-
 export dw_environment_query.16
 export dw_exec.17
 export dw_browse.18
@@ -19,6 +18,7 @@
 export dw_main_iteration.24
 export dw_app_dir.25
 export dw_main_quit.26
+export dw_shutdown.27
 
 export dw_box_new.40
 export dw_groupbox_new.41
--- a/win/dw-mingw.def	Fri Mar 01 13:01:59 2013 +0000
+++ b/win/dw-mingw.def	Fri Mar 01 16:51:08 2013 +0000
@@ -11,7 +11,6 @@
   dw_beep                                @13
   dw_messagebox                          @14
   dw_debug                               @15
-
   dw_environment_query                   @16
   dw_exec                                @17
   dw_browse                              @18
@@ -23,6 +22,7 @@
   dw_main_iteration                      @24
   dw_app_dir                             @25
   dw_main_quit                           @26
+  dw_shutdown                            @27
 
   dw_box_new                             @40
   dw_groupbox_new                        @41
--- a/win/dw.c	Fri Mar 01 13:01:59 2013 +0000
+++ b/win/dw.c	Fri Mar 01 16:51:08 2013 +0000
@@ -11331,10 +11331,8 @@
 
 /*
  * Cleanly terminates a DW session, should be signal handler safe.
- * Parameters:
- *       exitcode: Exit code reported to the operating system.
- */
-void API dw_exit(int exitcode)
+ */
+void API dw_shutdown(void)
 {
    OleUninitialize();
 #ifdef AEROGLASS
@@ -11343,6 +11341,16 @@
 #endif   
    FreeLibrary(huxtheme);
    DestroyWindow(hwndTooltip);
+}
+
+/*
+ * Cleanly terminates a DW session, should be signal handler safe.
+ * Parameters:
+ *       exitcode: Exit code reported to the operating system.
+ */
+void API dw_exit(int exitcode)
+{
+   dw_shutdown();
    exit(exitcode);
 }
 
--- a/win/dw.def	Fri Mar 01 13:01:59 2013 +0000
+++ b/win/dw.def	Fri Mar 01 16:51:08 2013 +0000
@@ -11,7 +11,6 @@
   dw_beep                                @13
   dw_messagebox                          @14
   dw_debug                               @15
-
   dw_environment_query                   @16
   dw_exec                                @17
   dw_browse                              @18
@@ -23,6 +22,7 @@
   dw_main_iteration                      @24
   dw_app_dir                             @25
   dw_main_quit                           @26
+  dw_shutdown                            @27
 
   dw_box_new                             @40
   dw_groupbox_new                        @41