changeset 1827:04c74cd0fb35

Test fix for crash changing bitmap on bitmap buttons on OS/2. Didn't notice that there was already code to free the pixmaps... So changing the bitmap on buttons that already had pixmaps crashed.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 29 Oct 2012 17:42:44 +0000
parents 10c59bb2c47f
children e0df1916b054
files os2/dw.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sun Oct 28 02:59:56 2012 +0000
+++ b/os2/dw.c	Mon Oct 29 17:42:44 2012 +0000
@@ -431,6 +431,14 @@
    HPIXMAP disable = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap_disabled");
    HPOINTER icon = (HPOINTER)dw_window_get_data(handle, "_dw_button_icon");
 
+   /* For safety purposes, reset all the window data */
+   dw_window_set_data(handle, "_dw_bitmap", NULL);
+   dw_window_set_data(handle, "_dw_hps", NULL);
+   dw_window_set_data(handle, "_dw_hdc", NULL);
+   dw_window_set_data(handle, "_dw_hpixmap", NULL);
+   dw_window_set_data(handle, "_dw_hpixmap_disabled", NULL);
+   dw_window_set_data(handle, "_dw_button_icon", NULL);
+   
    if(icon)
       WinDestroyPointer(icon);
 
@@ -7295,15 +7303,8 @@
        }
        else
        {
-           HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap");
-           HPIXMAP disabled = (HPIXMAP)dw_window_get_data(handle, "_dw_hpixmap_disabled");
-
-           if(pixmap)
-               dw_pixmap_destroy(pixmap);
-           if(disabled)
-               dw_pixmap_destroy(disabled);
-
-           pixmap = calloc(1,sizeof(struct _hpixmap));
+           HPIXMAP disabled, pixmap = calloc(1,sizeof(struct _hpixmap));
+
            pixmap->hbm = hbm;
            pixmap->hdc = hdc;
            pixmap->hps = hps;