[vlc-commits] qt4: fix COM leak and handle errors
Rémi Denis-Courmont
git at videolan.org
Sun Mar 29 15:00:43 CEST 2015
vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 28 16:30:47 2015 +0200| [0aa628a295071defdd0042e76ee863ca48cf8d62] | committer: Jean-Baptiste Kempf
qt4: fix COM leak and handle errors
(cherry picked from commit 39e4fad1bc929bb35a5353380b456e36f23ea1c4)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=0aa628a295071defdd0042e76ee863ca48cf8d62
---
modules/gui/qt4/components/simple_preferences.cpp | 34 ++++++++++++---------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp
index 6002648..06afde6 100644
--- a/modules/gui/qt4/components/simple_preferences.cpp
+++ b/modules/gui/qt4/components/simple_preferences.cpp
@@ -1254,37 +1254,41 @@ bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
return b_temp;
}
-void SPrefsPanel::assoDialog()
-{
#if !defined(__IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__)
#define __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__
const GUID IID_IApplicationAssociationRegistrationUI = {0x1f76a169,0xf994,0x40ac, {0x8f,0xc8,0x09,0x59,0xe8,0x87,0x47,0x10}};
const GUID CLSID_ApplicationAssociationRegistrationUI = { 0x1968106d,0xf3b5,0x44cf,{0x89,0x0e,0x11,0x6f,0xcb,0x9e,0xce,0xf1}};
-#ifdef __cplusplus
interface IApplicationAssociationRegistrationUI : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE LaunchAdvancedAssociationUI(
LPCWSTR pszAppRegName) = 0;
};
-#endif /* __cplusplus */
#endif /* __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__ */
- IApplicationAssociationRegistrationUI *p_appassoc;
- CoInitializeEx( NULL, COINIT_MULTITHREADED );
-
- if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
- NULL, CLSCTX_INPROC_SERVER,
- IID_IApplicationAssociationRegistrationUI,
- (void **)&p_appassoc) )
+void SPrefsPanel::assoDialog()
+{
+ HRESULT hr;
+ hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+ if( SUCCEEDED(hr) )
{
- if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
+ void *p;
+
+ hr = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
+ NULL, CLSCTX_INPROC_SERVER,
+ IID_IApplicationAssociationRegistrationUI, &p);
+ if( SUCCEEDED(hr) )
{
- CoUninitialize();
- return;
+ IApplicationAssociationRegistrationUI *p_regui =
+ (IApplicationAssociationRegistrationUI *)p;
+
+ hr = p_regui->LaunchAdvancedAssociationUI(L"VLC" );
+ p_regui->Release();
}
+ CoUninitialize();
}
- CoUninitialize();
+ if( SUCCEEDED(hr) )
+ return;
QDialog *d = new QDialog( this );
d->setWindowTitle( qtr( "File associations" ) );
More information about the vlc-commits
mailing list