Commit 19313bbf authored by Damien Fouilleul's avatar Damien Fouilleul

all: bug fixing, clean-up

parent 9131dbf7
...@@ -198,7 +198,8 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt ...@@ -198,7 +198,8 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt
pPropBag->Write(OLESTR("ExtentHeight"), &value); pPropBag->Write(OLESTR("ExtentHeight"), &value);
V_VT(&value) = VT_BSTR; V_VT(&value) = VT_BSTR;
V_BSTR(&value) = SysAllocString(_p_instance->getMRL()); V_BSTR(&value) = SysAllocStringLen(_p_instance->getMRL(),
SysStringLen(_p_instance->getMRL()));
pPropBag->Write(OLESTR("MRL"), &value); pPropBag->Write(OLESTR("MRL"), &value);
VariantClear(&value); VariantClear(&value);
......
...@@ -40,12 +40,12 @@ STDMETHODIMP VLCPersistStorage::IsDirty(void) ...@@ -40,12 +40,12 @@ STDMETHODIMP VLCPersistStorage::IsDirty(void)
return _p_instance->isDirty() ? S_OK : S_FALSE; return _p_instance->isDirty() ? S_OK : S_FALSE;
}; };
STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg) STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
{ {
return _p_instance->onInit(); return _p_instance->onInit();
}; };
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
{ {
if( NULL == pStg ) if( NULL == pStg )
return E_INVALIDARG; return E_INVALIDARG;
...@@ -69,7 +69,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) ...@@ -69,7 +69,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
return result; return result;
}; };
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
{ {
if( NULL == pStg ) if( NULL == pStg )
return E_INVALIDARG; return E_INVALIDARG;
......
...@@ -76,6 +76,7 @@ public: ...@@ -76,6 +76,7 @@ public:
VARIANT arg; VARIANT arg;
V_VT(&arg) = VT_BSTR; V_VT(&arg) = VT_BSTR;
V_BSTR(&arg) = bstr; V_BSTR(&arg) = bstr;
VariantInit(&_v);
VariantCopy(&_v, &arg); VariantCopy(&_v, &arg);
}; };
...@@ -153,7 +154,8 @@ public: ...@@ -153,7 +154,8 @@ public:
inline bool operator==(const AxVLCWSTR &s) const inline bool operator==(const AxVLCWSTR &s) const
{ {
return compareNoCase(s.wstr()) == 0; return size() == s.size() ?
(compareNoCase(s.wstr()) == 0) : false;
}; };
inline bool operator==(LPCWSTR s) const inline bool operator==(LPCWSTR s) const
...@@ -247,12 +249,15 @@ public: ...@@ -247,12 +249,15 @@ public:
if( notfound != iter ) if( notfound != iter )
{ {
VARTYPE vtype = V_VT(pVar); VARTYPE vtype = V_VT(pVar);
VariantCopy(pVar, const_cast<VARIANTARG*>((*iter).second.variantArg())); VARIANTARG v;
if( (V_VT(pVar) != vtype) && FAILED(VariantChangeType(pVar, pVar, 0, vtype)) ) VariantInit(&v);
VariantCopy(&v, const_cast<VARIANTARG*>((*iter).second.variantArg()));
if( (V_VT(&v) != vtype) && FAILED(VariantChangeType(&v, &v, 0, vtype)) )
{ {
VariantClear(pVar); VariantClear(&v);
return E_FAIL; return E_FAIL;
} }
*pVar = v;
return S_OK; return S_OK;
} }
else else
...@@ -400,7 +405,7 @@ private: ...@@ -400,7 +405,7 @@ private:
return result; return result;
}; };
static HRESULT ReadProperty(LPSTREAM pStm, AxVLCPropertyPair **prop) HRESULT ReadProperty(LPSTREAM pStm, AxVLCPropertyPair **prop)
{ {
HRESULT result; HRESULT result;
......
...@@ -102,7 +102,8 @@ static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam ...@@ -102,7 +102,8 @@ static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam
VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) : VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :
_p_class_ref(p_class_ref), _p_class_ref(p_class_ref),
_hinstance(hInstance) _hinstance(hInstance),
_inplace_picture(NULL)
{ {
WNDCLASS wClass; WNDCLASS wClass;
...@@ -303,7 +304,7 @@ VLCPlugin::~VLCPlugin() ...@@ -303,7 +304,7 @@ VLCPlugin::~VLCPlugin()
if( _p_pict ) if( _p_pict )
_p_pict->Release(); _p_pict->Release();
SysFreeString(_bstr_mrl), SysFreeString(_bstr_mrl);
_p_class->Release(); _p_class->Release();
}; };
...@@ -473,8 +474,7 @@ HRESULT VLCPlugin::onInit(void) ...@@ -473,8 +474,7 @@ HRESULT VLCPlugin::onInit(void)
{ {
if( 0 == _i_vlc ) if( 0 == _i_vlc )
{ {
//#ifdef ACTIVEX_DEBUG #ifdef ACTIVEX_DEBUG
#if 1
char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" }; char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" };
#else #else
char *ppsz_argv[] = { "vlc", "-vv" }; char *ppsz_argv[] = { "vlc", "-vv" };
...@@ -502,6 +502,11 @@ HRESULT VLCPlugin::onInit(void) ...@@ -502,6 +502,11 @@ HRESULT VLCPlugin::onInit(void)
#endif #endif
_i_vlc = VLC_Create(); _i_vlc = VLC_Create();
if( _i_vlc < 0 )
{
_i_vlc = 0;
return E_FAIL;
}
if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) ) if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) )
{ {
...@@ -519,7 +524,7 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -519,7 +524,7 @@ HRESULT VLCPlugin::onLoad(void)
if( _b_mute ) if( _b_mute )
VLC_VolumeMute(_i_vlc); VLC_VolumeMute(_i_vlc);
if( NULL != _bstr_mrl ) if( SysStringLen(_bstr_mrl) > 0 )
{ {
/* /*
** try to combine MRL with client site moniker, which for Internet Explorer ** try to combine MRL with client site moniker, which for Internet Explorer
...@@ -527,7 +532,7 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -527,7 +532,7 @@ HRESULT VLCPlugin::onLoad(void)
** is a relative URL, we should end up with an absolute URL ** is a relative URL, we should end up with an absolute URL
*/ */
IOleClientSite *pClientSite; IOleClientSite *pClientSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) ) if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
{ {
IBindCtx *pBC = 0; IBindCtx *pBC = 0;
if( SUCCEEDED(CreateBindCtx(0, &pBC)) ) if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
...@@ -549,7 +554,7 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -549,7 +554,7 @@ HRESULT VLCPlugin::onLoad(void)
URL_ESCAPE_UNSAFE)) ) URL_ESCAPE_UNSAFE)) )
{ {
SysFreeString(_bstr_mrl); SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(url); _bstr_mrl = SysAllocStringLen(url, len);
} }
CoTaskMemFree(url); CoTaskMemFree(url);
} }
......
...@@ -90,7 +90,7 @@ public: ...@@ -90,7 +90,7 @@ public:
void setMRL(BSTR mrl) void setMRL(BSTR mrl)
{ {
SysFreeString(_bstr_mrl); SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(mrl); _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
setDirty(TRUE); setDirty(TRUE);
}; };
const BSTR getMRL(void) { return _bstr_mrl; }; const BSTR getMRL(void) { return _bstr_mrl; };
......
...@@ -52,7 +52,7 @@ char *CStrFromBSTR(int codePage, BSTR bstr) ...@@ -52,7 +52,7 @@ char *CStrFromBSTR(int codePage, BSTR bstr)
BSTR BSTRFromCStr(int codePage, const char *s) BSTR BSTRFromCStr(int codePage, const char *s)
{ {
int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0); int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0);
if( wideLen ) if( wideLen > 0 )
{ {
WCHAR* wideStr = (WCHAR*)CoTaskMemAlloc(wideLen*sizeof(WCHAR)); WCHAR* wideStr = (WCHAR*)CoTaskMemAlloc(wideLen*sizeof(WCHAR));
if( NULL != wideStr ) if( NULL != wideStr )
...@@ -61,7 +61,7 @@ BSTR BSTRFromCStr(int codePage, const char *s) ...@@ -61,7 +61,7 @@ BSTR BSTRFromCStr(int codePage, const char *s)
ZeroMemory(wideStr, wideLen*sizeof(WCHAR)); ZeroMemory(wideStr, wideLen*sizeof(WCHAR));
MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen); MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen);
bstr = SysAllocString(wideStr); bstr = SysAllocStringLen(wideStr, wideLen);
free(wideStr); free(wideStr);
return bstr; return bstr;
......
...@@ -825,7 +825,8 @@ STDMETHODIMP VLCControl::get_MRL(BSTR *mrl) ...@@ -825,7 +825,8 @@ STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
if( NULL == mrl ) if( NULL == mrl )
return E_POINTER; return E_POINTER;
*mrl = SysAllocString(_p_instance->getMRL()); *mrl = SysAllocStringLen(_p_instance->getMRL(),
SysStringLen(_p_instance->getMRL()));
return NOERROR; return NOERROR;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment