Commit f9d4251e authored by Damien Fouilleul's avatar Damien Fouilleul

all: bug fixing, clean-up

parent 4f045bb1
......@@ -198,7 +198,8 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt
pPropBag->Write(OLESTR("ExtentHeight"), &value);
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);
VariantClear(&value);
......
......@@ -40,12 +40,12 @@ STDMETHODIMP VLCPersistStorage::IsDirty(void)
return _p_instance->isDirty() ? S_OK : S_FALSE;
};
STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
{
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
{
if( NULL == pStg )
return E_INVALIDARG;
......@@ -69,7 +69,7 @@ STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
return result;
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
{
if( NULL == pStg )
return E_INVALIDARG;
......
......@@ -76,6 +76,7 @@ public:
VARIANT arg;
V_VT(&arg) = VT_BSTR;
V_BSTR(&arg) = bstr;
VariantInit(&_v);
VariantCopy(&_v, &arg);
};
......@@ -153,7 +154,8 @@ public:
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
......@@ -247,12 +249,15 @@ public:
if( notfound != iter )
{
VARTYPE vtype = V_VT(pVar);
VariantCopy(pVar, const_cast<VARIANTARG*>((*iter).second.variantArg()));
if( (V_VT(pVar) != vtype) && FAILED(VariantChangeType(pVar, pVar, 0, vtype)) )
VARIANTARG v;
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;
}
*pVar = v;
return S_OK;
}
else
......@@ -400,7 +405,7 @@ private:
return result;
};
static HRESULT ReadProperty(LPSTREAM pStm, AxVLCPropertyPair **prop)
HRESULT ReadProperty(LPSTREAM pStm, AxVLCPropertyPair **prop)
{
HRESULT result;
......
......@@ -102,7 +102,8 @@ static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam
VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :
_p_class_ref(p_class_ref),
_hinstance(hInstance)
_hinstance(hInstance),
_inplace_picture(NULL)
{
WNDCLASS wClass;
......@@ -303,7 +304,7 @@ VLCPlugin::~VLCPlugin()
if( _p_pict )
_p_pict->Release();
SysFreeString(_bstr_mrl),
SysFreeString(_bstr_mrl);
_p_class->Release();
};
......@@ -473,8 +474,7 @@ HRESULT VLCPlugin::onInit(void)
{
if( 0 == _i_vlc )
{
//#ifdef ACTIVEX_DEBUG
#if 1
#ifdef ACTIVEX_DEBUG
char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" };
#else
char *ppsz_argv[] = { "vlc", "-vv" };
......@@ -502,6 +502,11 @@ HRESULT VLCPlugin::onInit(void)
#endif
_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) )
{
......@@ -519,7 +524,7 @@ HRESULT VLCPlugin::onLoad(void)
if( _b_mute )
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
......@@ -527,7 +532,7 @@ HRESULT VLCPlugin::onLoad(void)
** is a relative URL, we should end up with an absolute URL
*/
IOleClientSite *pClientSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) )
if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
{
IBindCtx *pBC = 0;
if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
......@@ -549,7 +554,7 @@ HRESULT VLCPlugin::onLoad(void)
URL_ESCAPE_UNSAFE)) )
{
SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(url);
_bstr_mrl = SysAllocStringLen(url, len);
}
CoTaskMemFree(url);
}
......
......@@ -90,7 +90,7 @@ public:
void setMRL(BSTR mrl)
{
SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(mrl);
_bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
setDirty(TRUE);
};
const BSTR getMRL(void) { return _bstr_mrl; };
......
......@@ -52,7 +52,7 @@ char *CStrFromBSTR(int codePage, BSTR bstr)
BSTR BSTRFromCStr(int codePage, const char *s)
{
int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0);
if( wideLen )
if( wideLen > 0 )
{
WCHAR* wideStr = (WCHAR*)CoTaskMemAlloc(wideLen*sizeof(WCHAR));
if( NULL != wideStr )
......@@ -61,7 +61,7 @@ BSTR BSTRFromCStr(int codePage, const char *s)
ZeroMemory(wideStr, wideLen*sizeof(WCHAR));
MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen);
bstr = SysAllocString(wideStr);
bstr = SysAllocStringLen(wideStr, wideLen);
free(wideStr);
return bstr;
......
......@@ -825,7 +825,8 @@ STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
if( NULL == mrl )
return E_POINTER;
*mrl = SysAllocString(_p_instance->getMRL());
*mrl = SysAllocStringLen(_p_instance->getMRL(),
SysStringLen(_p_instance->getMRL()));
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