X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/795b0f144495454aac0dc23e865f7a8f87f6dfa3..b85b06e13d22e7fc1604ec1a49caa1227a1b3d36:/src/msw/ole/oleutils.cpp diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index 8fbcf99885..3932c8d9ec 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -80,15 +80,22 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr) if ( !bStr ) return wxString(); + const int len = SysStringLen(bStr); + #if wxUSE_UNICODE - wxString str(bStr); + wxString str(bStr, len); #else - int len = SysStringLen(bStr) + 1; - char *buf = new char[len]; - (void)wcstombs( buf, bStr, len); - wxString str(buf); - delete[] buf; + wxString str; + if (len) + { + wxStringBufferLength buf(str, len); // asserts if len == 0 + buf.SetLength(WideCharToMultiByte(CP_ACP, 0 /* no flags */, + bStr, len /* not necessarily NUL-terminated */, + buf, len, + NULL, NULL /* no default char */)); + } #endif + return str; } @@ -123,7 +130,7 @@ wxBasicString::~wxBasicString() // Debug support // ---------------------------------------------------------------------------- -#if defined(__WXDEBUG__) && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) ) +#if wxDEBUG_LEVEL && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) ) static wxString GetIidName(REFIID riid) { // an association between symbolic name and numeric value of an IID @@ -251,31 +258,10 @@ void wxLogRelease(const wxChar *szInterface, ULONG cRef) wxLogTrace(wxTRACE_OleCalls, wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1); } -#elif defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ <= 1000) - -// For VC++ 4 -void wxLogQueryInterface(const char *szInterface, REFIID riid) -{ - wxLogTrace("%s::QueryInterface", szInterface); -} - -void wxLogAddRef(const char *szInterface, ULONG cRef) -{ - wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface, cRef + 1); -} - -void wxLogRelease(const char *szInterface, ULONG cRef) -{ - wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1); -} - -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL -#endif - // wxUSE_DRAG_AND_DROP +#endif // wxUSE_DRAG_AND_DROP -#endif - // __CYGWIN10__ +#endif // __CYGWIN10__ -#endif - // wxUSE_OLE +#endif // wxUSE_OLE