From: Vadim Zeitlin Date: Thu, 13 Sep 2012 17:13:28 +0000 (+0000) Subject: Change wxMSW-specific wxLoadUserResource() to accept standard RT_XXX types. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e23fd60fe7f9f6b2060d6086729a7f350f6d2709?ds=inline Change wxMSW-specific wxLoadUserResource() to accept standard RT_XXX types. 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 --- diff --git a/include/wx/utils.h b/include/wx/utils.h index c131fbb9ce..1eed877f4b 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -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__ diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index abab0a651a..b5e56d50f7 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -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) {