]> git.saurik.com Git - wxWidgets.git/commitdiff
Change wxMSW-specific wxLoadUserResource() to accept standard RT_XXX types.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 13 Sep 2012 17:13:28 +0000 (17:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 13 Sep 2012 17:13:28 +0000 (17:13 +0000)
Resource types can be either strings for custom types or integers casted to a
TCHAR* for the standard ones. Using wxString for the resource type prevented
us from using the latter as any attempt to initialize wxString for such a
pseudo-string resulted in an immediate crash.

Change wxLoadUserResource() resource type parameter type to wxChar* to avoid
this and allow passing standard resource types, such as RT_RCDATE, to this
function directly.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/utils.h
src/msw/utils.cpp

index c131fbb9ce71d73ac01ff9e6f3163264013bf597..1eed877f4bff3d3b145b8f0f39325a9c319ef3fa 100644 (file)
@@ -818,6 +818,10 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
     // Return the pointer to the resource data. This pointer is read-only, use
     // the overload below if you need to modify the data.
     //
+    // Notice that the resource type can be either a real string or an integer
+    // produced by MAKEINTRESOURCE(). In particular, any standard resource type,
+    // i.e any RT_XXX constant, could be passed here.
+    //
     // Returns true on success, false on failure. Doesn't log an error message
     // if the resource is not found (because this could be expected) but does
     // log one if any other error occurs.
@@ -825,7 +829,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
     wxLoadUserResource(const void **outData,
                        size_t *outLen,
                        const wxString& resourceName,
-                       const wxString& resourceType = wxUserResourceStr,
+                       const wxChar* resourceType = wxUserResourceStr,
                        WXHINSTANCE module = 0);
 
     // This function allocates a new buffer and makes a copy of the resource
@@ -835,7 +839,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
     // Returns NULL on failure.
     WXDLLIMPEXP_BASE char*
     wxLoadUserResource(const wxString& resourceName,
-                       const wxString& resourceType = wxUserResourceStr,
+                       const wxChar* resourceType = wxUserResourceStr,
                        int* pLen = NULL,
                        WXHINSTANCE module = 0);
 #endif // __WINDOWS__
index abab0a651a9490a98b5c12d908935842fc88c1df..b5e56d50f74cccc2d84c818c3ef797797cf917ca 100644 (file)
@@ -1103,14 +1103,14 @@ bool
 wxLoadUserResource(const void **outData,
                    size_t *outLen,
                    const wxString& resourceName,
-                   const wxString& resourceType,
+                   const wxChar* resourceType,
                    WXHINSTANCE instance)
 {
     wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" );
 
     HRSRC hResource = ::FindResource(instance,
                                      resourceName.t_str(),
-                                     resourceType.t_str());
+                                     resourceType);
     if ( !hResource )
         return false;
 
@@ -1139,7 +1139,7 @@ wxLoadUserResource(const void **outData,
 
 char *
 wxLoadUserResource(const wxString& resourceName,
-                   const wxString& resourceType,
+                   const wxChar* resourceType,
                    int* pLen,
                    WXHINSTANCE instance)
 {