]> git.sesse.net Git - vlc/commitdiff
Win32: get rid of calls to GetVersion (CoCreateInstance will fail anyway if the featu...
authorGeoffroy Couprie <geal@videolan.org>
Tue, 19 Jan 2010 14:13:33 +0000 (15:13 +0100)
committerGeoffroy Couprie <geal@videolan.org>
Sun, 24 Jan 2010 18:58:20 +0000 (19:58 +0100)
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/simple_preferences.cpp
modules/gui/qt4/main_interface.cpp

index 930b6ded7f4dd1cea0c43e2092c3e5ef8be93138..50c16477bf6975f8099024684e4359d9b5178a6f 100644 (file)
@@ -239,28 +239,25 @@ void VideoWidget::release( void )
 #ifdef WIN32
     /* Come back to default thumbnail for Windows 7 taskbar */
     LPTASKBARLIST3 p_taskbl;
-    OSVERSIONINFO winVer;
-    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
-    {
-        CoInitialize( 0 );
 
-        if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
-                    NULL, CLSCTX_INPROC_SERVER,
-                    &IID_ITaskbarList3,
-                    (void **)&p_taskbl) )
-        {
-            p_taskbl->vt->HrInit(p_taskbl);
+    CoInitialize( 0 );
+
+    if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+                NULL, CLSCTX_INPROC_SERVER,
+                &IID_ITaskbarList3,
+                (void **)&p_taskbl) )
+    {
+        p_taskbl->vt->HrInit(p_taskbl);
 
-            HWND hroot = GetAncestor(reparentable->winId(),GA_ROOT);
+        HWND hroot = GetAncestor(reparentable->winId(),GA_ROOT);
 
-            if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, NULL))
-                msg_Err(p_intf, "SetThumbNailClip failed");
-            msg_Err(p_intf, "Releasing taskbar | root handle = %08x", hroot);
-            p_taskbl->vt->Release(p_taskbl);
-        }
-        CoUninitialize();
+        if (S_OK != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, NULL))
+            msg_Err(p_intf, "SetThumbNailClip failed");
+        msg_Err(p_intf, "Releasing taskbar | root handle = %08x", hroot);
+        p_taskbl->vt->Release(p_taskbl);
     }
+    CoUninitialize();
+
 #endif
 
     delete reparentable;
index e8542daa5ee45b0c2edd675ae7f3a485565dfdb5..8927cf0c62b54a46d4d50bcb5f9c2072b1b7683e 100644 (file)
@@ -859,28 +859,23 @@ bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
 
 void SPrefsPanel::assoDialog()
 {
-    OSVERSIONINFO winVer;
-    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    //Vista specific file associations
-    if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
-    {
-            LPAPPASSOCREGUI p_appassoc;
-            CoInitialize( 0 );
-
-            if( S_OK == CoCreateInstance( &clsid_IApplication2,
-                        NULL, CLSCTX_INPROC_SERVER,
-                        &IID_IApplicationAssociationRegistrationUI,
-                        (void **)&p_appassoc) )
-            {
-                if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
-                {
-                    CoUninitialize();
-                    return;
-                }
-            }
+    LPAPPASSOCREGUI p_appassoc;
+    CoInitialize( 0 );
 
+    if( S_OK == CoCreateInstance( &clsid_IApplication2,
+                NULL, CLSCTX_INPROC_SERVER,
+                &IID_IApplicationAssociationRegistrationUI,
+                (void **)&p_appassoc) )
+    {
+        if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
+        {
             CoUninitialize();
+            return;
+        }
     }
+
+    CoUninitialize();
+
     QDialog *d = new QDialog( this );
     QGridLayout *assoLayout = new QGridLayout( d );
 
index 8b6530c5ddecba9d8669369944ca28352114829d..763d760b36fae974b471d307e6b547fb611b0d27 100644 (file)
@@ -519,16 +519,22 @@ void MainInterface::createTaskBarButtons()
     FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
     FIXME:the play button's picture doesn't changed to pause when clicked
     */
-    OSVERSIONINFO winVer;
-    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
+
+    CoInitialize( 0 );
+
+    if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+                NULL, CLSCTX_INPROC_SERVER,
+                &IID_ITaskbarList3,
+                (void **)&p_taskbl) )
     {
+        p_taskbl->vt->HrInit(p_taskbl);
+
         if(himl = ImageList_Create( 15, //cx
-                                    18, //cy
-                                    ILC_COLOR,//flags
-                                    4,//initial nb of images
-                                    0//nb of images that can be added
-                                    ))
+                        18, //cy
+                        ILC_COLOR,//flags
+                        4,//initial nb of images
+                        0//nb of images that can be added
+                        ))
         {
             QPixmap img   = QPixmap(":/toolbar/previous_b");
             QPixmap img2  = QPixmap(":/toolbar/pause_b");
@@ -549,52 +555,43 @@ void MainInterface::createTaskBarButtons()
                 msg_Err( p_intf, "ImageList_Add failed" );
         }
 
-        CoInitialize( 0 );
-
-        if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
-                    NULL, CLSCTX_INPROC_SERVER,
-                    &IID_ITaskbarList3,
-                    (void **)&p_taskbl) )
+        // Define an array of two buttons. These buttons provide images through an
+        // image list and also provide tooltips.
+        DWORD dwMask = THB_BITMAP | THB_FLAGS;
+
+        THUMBBUTTON thbButtons[3];
+        thbButtons[0].dwMask = dwMask;
+        thbButtons[0].iId = 0;
+        thbButtons[0].iBitmap = 0;
+        thbButtons[0].dwFlags = THBF_HIDDEN;
+
+        thbButtons[1].dwMask = dwMask;
+        thbButtons[1].iId = 1;
+        thbButtons[1].iBitmap = 2;
+        thbButtons[1].dwFlags = THBF_HIDDEN;
+
+        thbButtons[2].dwMask = dwMask;
+        thbButtons[2].iId = 2;
+        thbButtons[2].iBitmap = 3;
+        thbButtons[2].dwFlags = THBF_HIDDEN;
+
+        HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
+        if(S_OK != hr)
+            msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
+        else
         {
-            p_taskbl->vt->HrInit(p_taskbl);
-
-            // Define an array of two buttons. These buttons provide images through an
-            // image list and also provide tooltips.
-            DWORD dwMask = THB_BITMAP | THB_FLAGS;
-
-            THUMBBUTTON thbButtons[3];
-            thbButtons[0].dwMask = dwMask;
-            thbButtons[0].iId = 0;
-            thbButtons[0].iBitmap = 0;
-            thbButtons[0].dwFlags = THBF_HIDDEN;
-
-            thbButtons[1].dwMask = dwMask;
-            thbButtons[1].iId = 1;
-            thbButtons[1].iBitmap = 2;
-            thbButtons[1].dwFlags = THBF_HIDDEN;
-
-            thbButtons[2].dwMask = dwMask;
-            thbButtons[2].iId = 2;
-            thbButtons[2].iBitmap = 3;
-            thbButtons[2].dwFlags = THBF_HIDDEN;
-
-            HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
+            hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
             if(S_OK != hr)
-                msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
-            else
-            {
-                hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
-                if(S_OK != hr)
-                    msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr );
-            }
-            CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
+                msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr );
         }
+        CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
     }
     else
     {
         himl = NULL;
         p_taskbl = NULL;
     }
+
 }
 
 bool MainInterface::winEvent ( MSG * msg, long * result )