]> git.sesse.net Git - vlc/commitdiff
all: bug fixing, clean-up
authorDamien Fouilleul <damienf@videolan.org>
Fri, 16 Sep 2005 16:10:42 +0000 (16:10 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Fri, 16 Sep 2005 16:10:42 +0000 (16:10 +0000)
activex/persistpropbag.cpp
activex/persiststorage.cpp
activex/persiststreaminit.cpp
activex/plugin.cpp
activex/plugin.h
activex/utils.cpp
activex/vlccontrol.cpp

index 1f036f06d02298000177205e49bb4183e9975946..f70a665c9c86adf6da265f063b1b466abcfdbaa3 100644 (file)
@@ -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);
 
index 7c7eb8222b93a82a46c3fbd60de79d713c2f9824..1e01eddfee14280aabc0ef1fe34ad6c0f4c63101 100644 (file)
@@ -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;
index c62736e9434c36bc1002aa0fd19f52a4065aab4d..617973866b0d0f11694841308f2265735364d2d9 100644 (file)
@@ -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;
 
index 67a8965bc53d2c3fc14c0da6187ad9b801c273bf..8f14ba989b448f53a223600c69cc9152cd7632d9 100644 (file)
@@ -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);
                             }
index f95aef55f0635efeccda0ad0eef47d9a45a74310..227773a8aa0fcda2c8a7253f624de64a7db76cdf 100644 (file)
@@ -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; };
index fb0a550e42268a436a801b255cffa4aacf105917..7582adaef0b9b664b0277236bafc6b35e1246241 100644 (file)
@@ -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;
index 364cf3f085e2bfc1b65340a9ba09b468f55710b0..4edaefb4f7412a2fc3c6142ccf3873f1d4791422 100644 (file)
@@ -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;
 };