]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxNullPtr and use it instead of just 0 with wxFileTypeInfo vararg ctor to fix...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 13 Jun 2007 11:32:44 +0000 (11:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 13 Jun 2007 11:32:44 +0000 (11:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/mimetype.h
src/common/filesys.cpp

index d5fc6c3c56fb3770e8cb801460736984ce4a6ba7..ef32c34068fe808d131bbff96fa5e31c17529c36 100644 (file)
@@ -1141,6 +1141,18 @@ typedef float wxFloat32;
 #   endif
 #endif /* wxUSE_WCHAR_T */
 
+/*
+   This constant should be used instead of NULL in vararg functions taking
+   wxChar* arguments: passing NULL (which is the same as 0, unless the compiler
+   defines it specially, e.g. like gcc does with its __null built-in) doesn't
+   work in this case as va_arg() wouldn't interpret the integer 0 correctly
+   when trying to convert it to a pointer on architectures where sizeof(int) is
+   strictly less than sizeof(void *).
+
+   Examples of places where this must be used include wxFileTypeInfo ctor.
+ */
+#define wxNullPtr ((void *)NULL)
+
 /*  ---------------------------------------------------------------------------- */
 /*  byte ordering related definition and macros */
 /*  ---------------------------------------------------------------------------- */
index b0f732f08f15d3146ec0bd62834fcec2cefc6e57..515cf345216611845e0f3b419704fcb51089728d 100644 (file)
@@ -151,8 +151,9 @@ public:
     //               const wxString& openCmd,
     //               const wxString& printCmd,
     //               const wxString& desc,
-    //               // the other parameters form a NULL terminated list of
-    //               // extensions
+    //               // the other parameters form a list of extensions for this
+    //               // file type and should be terminated with wxNullPtr (not
+    //               // just NULL!)
     //               ...);
     WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
                                // NB: these are not format strings, using
index 94a229f49c5d280494719a6459c3b710e94d5534..4b3bb49c593afc086519d0383b2f73856280b44d 100644 (file)
@@ -69,27 +69,27 @@ wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
                            wxEmptyString,
                            wxEmptyString,
                            _T("JPEG image (from fallback)"),
-                           _T("jpg"), _T("jpeg"), _T("JPG"), _T("JPEG"), 0),
+                           _T("jpg"), _T("jpeg"), _T("JPG"), _T("JPEG"), wxNullPtr),
             wxFileTypeInfo(_T("image/gif"),
                            wxEmptyString,
                            wxEmptyString,
                            _T("GIF image (from fallback)"),
-                           _T("gif"), _T("GIF"), 0),
+                           _T("gif"), _T("GIF"), wxNullPtr),
             wxFileTypeInfo(_T("image/png"),
                            wxEmptyString,
                            wxEmptyString,
                            _T("PNG image (from fallback)"),
-                           _T("png"), _T("PNG"), 0),
+                           _T("png"), _T("PNG"), wxNullPtr),
             wxFileTypeInfo(_T("image/bmp"),
                            wxEmptyString,
                            wxEmptyString,
                            _T("windows bitmap image (from fallback)"),
-                           _T("bmp"), _T("BMP"), 0),
+                           _T("bmp"), _T("BMP"), wxNullPtr),
             wxFileTypeInfo(_T("text/html"),
                            wxEmptyString,
                            wxEmptyString,
                            _T("HTML document (from fallback)"),
-                           _T("htm"), _T("html"), _T("HTM"), _T("HTML"), 0),
+                           _T("htm"), _T("html"), _T("HTM"), _T("HTML"), wxNullPtr),
             // must terminate the table with this!
             wxFileTypeInfo()
         };