changeset 648:2b260f4309bb

Put in a fix for a Visual Studio 2008 crash with a time of 0. Also changed DEBUG to be DWDEBUG so the popup boxes don't fill the screen when making a simple debug build.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 19 Feb 2011 00:02:12 +0000
parents f09977bc9b5c
children 3e2ada9ee0ac
files win/dw.c
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Sat Feb 19 00:00:19 2011 +0000
+++ b/win/dw.c	Sat Feb 19 00:02:12 2011 +0000
@@ -1551,7 +1551,7 @@
    }
 }
 
-#ifdef DEBUG
+#ifdef DWDEBUG
 long ProcessCustomDraw (LPARAM lParam)
 {
     LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
@@ -1965,7 +1965,7 @@
                                  }
                               }
                            }
-#ifdef DEBUG
+#ifdef DWDEBUG
                            else if ( lem->hdr.code == NM_CUSTOMDRAW )
                            {
 dw_messagebox("NM_CUSTOMDRAW for WC_LISTVIEW from _wndproc (WM_NOTIFY)", DW_MB_OK|DW_MB_ERROR, "Hello");
@@ -2188,7 +2188,7 @@
 
             _resize_notebook_page(tem->hwndFrom, num);
          }
-#ifdef DEBUG
+#ifdef DWDEBUG
          else
          {
             /*
@@ -7663,11 +7663,22 @@
       struct tm curtm;
       CDATE cdate = *((CDATE *)data);
 
-      curtm.tm_mday = cdate.day;
-      curtm.tm_mon = cdate.month - 1;
-      curtm.tm_year = cdate.year - 1900;
-
-      strftime(textbuffer, 100, "%x", &curtm);
+
+	  /* Safety check... zero dates are crashing
+	   * Visual Studio 2008. -Brian
+	   */
+	  if(cdate.year > 1900)
+	  {
+		  curtm.tm_mday = cdate.day;
+		  curtm.tm_mon = cdate.month > 0 ? cdate.month - 1 : 0;
+		  curtm.tm_year = cdate.year - 1900;
+
+		  strftime(textbuffer, 100, "%x", &curtm);
+	  }
+	  else
+	  {
+		  textbuffer[0] = 0;
+	  }
 
       lvi.pszText = textbuffer;
       lvi.cchTextMax = strlen(textbuffer);