From: Vadim Zeitlin Date: Wed, 23 May 2012 21:16:45 +0000 (+0000) Subject: Fix wxBase compilation with UTF-8-based wxString under MSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b2b6da49e2184e17b4993dd37448cf0156d8b143 Fix wxBase compilation with UTF-8-based wxString under MSW. Use wxString::t_str() instead of wx_str() in Windows API function calls. Closes #14325. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 84a8530d22..2fb3acad3b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -576,6 +576,7 @@ MSW: - Fix handling of composite windows in wxToolTip (Armel Asselin). - Add VT_I8 support to wxAutomationObject (PB). - Fix wxListbook size calculations to avoid spurious scrollbars. +- Fix non-GUI code compilation with wxUSE_UNICODE_UTF8 (Kolya Kosenko). OSX: diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index e10734beaa..3671f0ee0e 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -1190,7 +1190,7 @@ bool DoShowAssertDialog(const wxString& msg) wxT("You can also choose [Cancel] to suppress ") wxT("further warnings."); - switch ( ::MessageBox(NULL, msgDlg.wx_str(), wxT("wxWidgets Debug Alert"), + switch ( ::MessageBox(NULL, msgDlg.t_str(), wxT("wxWidgets Debug Alert"), MB_YESNOCANCEL | MB_ICONSTOP ) ) { case IDYES: diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index 484fe0f883..656359a6b2 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -435,6 +435,8 @@ class wxPrintfFormatConverterWchar : public wxFormatConverterBase }; #endif // !wxUSE_UTF8_LOCALE_ONLY +#endif // __WINDOWS__/!__WINDOWS__ + #if wxUSE_UNICODE_UTF8 class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase { @@ -458,8 +460,6 @@ class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase }; #endif // wxUSE_UNICODE_UTF8 -#endif // __WINDOWS__/!__WINDOWS__ - #if !wxUSE_UNICODE // FIXME-UTF8: remove class wxPrintfFormatConverterANSI : public wxFormatConverterBase { diff --git a/src/msw/crashrpt.cpp b/src/msw/crashrpt.cpp index 4bf374f676..e618107487 100644 --- a/src/msw/crashrpt.cpp +++ b/src/msw/crashrpt.cpp @@ -247,7 +247,7 @@ bool wxCrashReportImpl::Generate(int flags, EXCEPTION_POINTERS *ep) /* static */ void wxCrashReport::SetFileName(const wxString& filename) { - wxStrlcpy(gs_reportFilename, filename.wx_str(), WXSIZEOF(gs_reportFilename)); + wxStrlcpy(gs_reportFilename, filename.t_str(), WXSIZEOF(gs_reportFilename)); } /* static */ diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index bb85ac799a..10f0dc792a 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -1068,7 +1068,7 @@ static HSZ DDEAtomFromString(const wxString& s) { wxASSERT_MSG( DDEIdInst, wxT("DDE not initialized") ); - HSZ hsz = DdeCreateStringHandle(DDEIdInst, (wxChar*)s.wx_str(), DDE_CP); + HSZ hsz = DdeCreateStringHandle(DDEIdInst, const_cast(static_cast(s.t_str())), DDE_CP); if ( !hsz ) { DDELogError(_("Failed to create DDE string")); diff --git a/src/msw/debughlp.cpp b/src/msw/debughlp.cpp index 40396b7b19..927c293a86 100644 --- a/src/msw/debughlp.cpp +++ b/src/msw/debughlp.cpp @@ -146,7 +146,7 @@ const wxString& wxDbgHelpDLL::GetErrorMessage() void wxDbgHelpDLL::LogError(const wxChar *func) { ::OutputDebugString(wxString::Format(wxT("dbghelp: %s() failed: %s\r\n"), - func, wxSysErrorMsg(::GetLastError())).wx_str()); + func, wxSysErrorMsg(::GetLastError())).t_str()); } // ---------------------------------------------------------------------------- diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 948d9249fb..80903a6e4d 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -1057,7 +1057,7 @@ bool wxRegKey::SetValue(const wxString& szValue, const wxString& strValue) m_dwLastError = RegSetValueEx((HKEY) m_hKey, RegValueStr(szValue), (DWORD) RESERVED, REG_SZ, - (RegString)strValue.t_str(), + (RegString)static_cast(strValue.t_str()), (strValue.Len() + 1)*sizeof(wxChar)); if ( m_dwLastError == ERROR_SUCCESS ) return true; diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 9c2d759051..d672e75d5d 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1115,8 +1115,8 @@ wxLoadUserResource(const void **outData, wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" ); HRSRC hResource = ::FindResource(instance, - resourceName.wx_str(), - resourceType.wx_str()); + resourceName.t_str(), + resourceType.t_str()); if ( !hResource ) return false; diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 734ca45d11..ae2558770e 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -857,14 +857,14 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, // WinCE requires appname to be non null // Win32 allows for null #ifdef __WXWINCE__ - (wxChar *) - moduleName.wx_str(),// application name - (wxChar *) - arguments.wx_str(), // arguments + static_cast( + moduleName.t_str()),// application name + const_cast(static_cast( + arguments.t_str())), // arguments #else NULL, // application name (use only cmd line) - (wxChar *) - command.wx_str(), // full command line + const_cast(static_cast( + command.t_str())), // full command line #endif NULL, // security attributes: defaults for both NULL, // the process and its main thread @@ -872,7 +872,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, dwFlags, // process creation flags envBuffer.data(), // environment (may be NULL which is fine) useCwd // initial working directory - ? const_cast(env->cwd.wx_str()) + ? const_cast(static_cast(env->cwd.t_str())) : NULL, // (or use the same) &si, // startup info (unused here) &pi // process info diff --git a/src/msw/volume.cpp b/src/msw/volume.cpp index 3ea20ccae4..5414ddb7ad 100644 --- a/src/msw/volume.cpp +++ b/src/msw/volume.cpp @@ -288,7 +288,7 @@ static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc, // The filter function will not know mounted from unmounted, and neither do we unless // we are iterating using RESOURCE_CONNECTED, in which case they all are mounted. // Volumes on disconnected servers, however, will correctly show as unmounted. - FilteredAdd(list, filename.wx_str(), flagsSet, flagsUnset&~wxFS_VOL_MOUNTED); + FilteredAdd(list, filename.t_str(), flagsSet, flagsUnset&~wxFS_VOL_MOUNTED); if (scope == RESOURCE_GLOBALNET) s_fileInfo[filename].m_flags &= ~wxFS_VOL_MOUNTED; } @@ -502,7 +502,7 @@ bool wxFSVolumeBase::Create(const wxString& name) // Display name. SHFILEINFO fi; - long rc = SHGetFileInfo(m_volName.wx_str(), 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME); + long rc = SHGetFileInfo(m_volName.t_str(), 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME); if (!rc) { wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());