Replace calls to deprecated wxBasicString::Get() with calls to wxBasicString::Detach() which is not deprecated but also more efficient in cases like these.

This commit is contained in:
PB
2017-06-23 17:32:03 +02:00
parent 60563ce0ce
commit 9030d9390a
4 changed files with 22 additions and 28 deletions

View File

@@ -1127,7 +1127,7 @@ bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
if(pPlay) if(pPlay)
{ {
pPlay->put_UseHTTPProxy(VARIANT_TRUE); pPlay->put_UseHTTPProxy(VARIANT_TRUE);
pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get()); pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Detach());
pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort())); pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort()));
pPlay->Release(); pPlay->Release();
} }
@@ -1150,9 +1150,9 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
// the docs say its async and put_FileName is not - // the docs say its async and put_FileName is not -
// but in practice they both seem to be async anyway // but in practice they both seem to be async anyway
if(GetMP()) if(GetMP())
hr = GetMP()->Open( wxBasicString(location).Get() ); hr = GetMP()->Open( wxBasicString(location).Detach() );
else else
hr = GetAM()->put_FileName( wxBasicString(location).Get() ); hr = GetAM()->put_FileName( wxBasicString(location).Detach() );
if(FAILED(hr)) if(FAILED(hr))
{ {

View File

@@ -909,17 +909,17 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
) == 0 && ) == 0 &&
pWMPNetwork->setProxySettings( pWMPNetwork->setProxySettings(
wxBasicString(location.GetScheme()).Get(), // protocol wxBasicString(location.GetScheme()).Detach(), // protocol
2) == 0) // 2 == manually specify 2) == 0) // 2 == manually specify
{ {
BSTR bsOldName = NULL; BSTR bsOldName = NULL;
long lOldPort = 0; long lOldPort = 0;
pWMPNetwork->getProxyName( pWMPNetwork->getProxyName(
wxBasicString(location.GetScheme()).Get(), wxBasicString(location.GetScheme()).Detach(),
&bsOldName); &bsOldName);
pWMPNetwork->getProxyPort( pWMPNetwork->getProxyPort(
wxBasicString(location.GetScheme()).Get(), wxBasicString(location.GetScheme()).Detach(),
&lOldPort); &lOldPort);
long lPort; long lPort;
@@ -936,11 +936,11 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
} }
if( pWMPNetwork->setProxyName( if( pWMPNetwork->setProxyName(
wxBasicString(location.GetScheme()).Get(), // proto wxBasicString(location.GetScheme()).Detach(), // proto
wxBasicString(server).Get() ) == 0 && wxBasicString(server).Get() ) == 0 &&
pWMPNetwork->setProxyPort( pWMPNetwork->setProxyPort(
wxBasicString(location.GetScheme()).Get(), // proto wxBasicString(location.GetScheme()).Detach(), // proto
lPort lPort
) == 0 ) == 0
) )
@@ -948,16 +948,16 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
bOK = DoLoad(location.BuildURI()); bOK = DoLoad(location.BuildURI());
pWMPNetwork->setProxySettings( pWMPNetwork->setProxySettings(
wxBasicString(location.GetScheme()).Get(), // protocol wxBasicString(location.GetScheme()).Detach(), // protocol
lOldSetting); lOldSetting);
if(bsOldName) if(bsOldName)
pWMPNetwork->setProxyName( pWMPNetwork->setProxyName(
wxBasicString(location.GetScheme()).Get(), // protocol wxBasicString(location.GetScheme()).Detach(), // protocol
bsOldName); bsOldName);
if(lOldPort) if(lOldPort)
pWMPNetwork->setProxyPort( pWMPNetwork->setProxyPort(
wxBasicString(location.GetScheme()).Get(), // protocol wxBasicString(location.GetScheme()).Detach(), // protocol
lOldPort); lOldPort);
pWMPNetwork->Release(); pWMPNetwork->Release();
@@ -1012,7 +1012,7 @@ bool wxWMP10MediaBackend::DoLoad(const wxString& location)
#endif #endif
{ {
// just load it the "normal" way // just load it the "normal" way
hr = m_pWMPPlayer->put_URL( wxBasicString(location).Get() ); hr = m_pWMPPlayer->put_URL( wxBasicString(location).Detach() );
} }
if(FAILED(hr)) if(FAILED(hr))
@@ -1061,12 +1061,12 @@ bool wxWMP10MediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
if(!flags) if(!flags)
{ {
m_pWMPPlayer->put_enabled(VARIANT_FALSE); m_pWMPPlayer->put_enabled(VARIANT_FALSE);
m_pWMPPlayer->put_uiMode(wxBasicString(wxT("none")).Get()); m_pWMPPlayer->put_uiMode(wxBasicString(wxT("none")).Detach());
} }
else else
{ {
// TODO: use "custom"? (note that CE only supports none/full) // TODO: use "custom"? (note that CE only supports none/full)
m_pWMPPlayer->put_uiMode(wxBasicString(wxT("full")).Get()); m_pWMPPlayer->put_uiMode(wxBasicString(wxT("full")).Detach());
m_pWMPPlayer->put_enabled(VARIANT_TRUE); m_pWMPPlayer->put_enabled(VARIANT_TRUE);
} }
@@ -1358,7 +1358,7 @@ wxLongLong wxWMP10MediaBackend::GetDownloadTotal()
if(m_pWMPPlayer->get_currentMedia(&pWMPMedia) == 0) if(m_pWMPPlayer->get_currentMedia(&pWMPMedia) == 0)
{ {
BSTR bsOut; BSTR bsOut;
pWMPMedia->getItemInfo(wxBasicString(wxT("FileSize")).Get(), pWMPMedia->getItemInfo(wxBasicString(wxT("FileSize")).Detach(),
&bsOut); &bsOut);
wxString sFileSize = wxConvertStringFromOle(bsOut); wxString sFileSize = wxConvertStringFromOle(bsOut);

View File

@@ -938,8 +938,7 @@ STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefau
} }
else else
{ {
wxBasicString basicString(defaultAction); * pszDefaultAction = wxBasicString(defaultAction).Detach();
* pszDefaultAction = basicString.Get();
return S_OK; return S_OK;
} }
} }
@@ -999,8 +998,7 @@ STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescrip
} }
else else
{ {
wxBasicString basicString(description); * pszDescription = wxBasicString(description).Detach();
* pszDescription = basicString.Get();
return S_OK; return S_OK;
} }
} }
@@ -1060,8 +1058,7 @@ STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp)
} }
else else
{ {
wxBasicString basicString(helpString); * pszHelp = wxBasicString(helpString).Detach();
* pszHelp = basicString.Get();
return S_OK; return S_OK;
} }
} }
@@ -1171,8 +1168,7 @@ STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKe
} }
else else
{ {
wxBasicString basicString(keyboardShortcut); * pszKeyboardShortcut = wxBasicString(keyboardShortcut).Detach();
* pszKeyboardShortcut = basicString.Get();
return S_OK; return S_OK;
} }
} }
@@ -1235,8 +1231,7 @@ STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName)
} }
else else
{ {
wxBasicString basicString(name); *pszName = wxBasicString(name).Detach();
*pszName = basicString.Get();
} }
return S_OK; return S_OK;
} }
@@ -1416,8 +1411,7 @@ STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue)
} }
else else
{ {
wxBasicString basicString(strValue); * pszValue = wxBasicString(strValue).Detach();
* pszValue = basicString.Get();
return S_OK; return S_OK;
} }
} }

View File

@@ -38,7 +38,7 @@
WXDLLEXPORT BSTR wxConvertStringToOle(const wxString& str) WXDLLEXPORT BSTR wxConvertStringToOle(const wxString& str)
{ {
return wxBasicString(str).Get(); return wxBasicString(str).Detach();
} }
WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr) WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)