Rob Shearman : ole32: Fix hosting in main apartments.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 21 09:40:17 CDT 2007


Module: wine
Branch: master
Commit: be55a4bbe28a5666b47e2e2b62c008bbffc9b6e3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=be55a4bbe28a5666b47e2e2b62c008bbffc9b6e3

Author: Rob Shearman <rob at codeweavers.com>
Date:   Sat May 19 17:21:00 2007 +0100

ole32: Fix hosting in main apartments.

The recently introduced code had a bug where it passed the wrong
values into apartment_findfromtype to find the main apartment. Since
this is now the only way the function is used, fix this bug by
changing apartment_findfromtype to apartment_findmain, which only
finds the main apartment.

---

 dlls/ole32/compobj.c |   29 +++++++----------------------
 1 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 8e883a8..d9404a1 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -474,33 +474,18 @@ APARTMENT *apartment_findfromtid(DWORD tid)
     return result;
 }
 
-/* gets an apartment which has a given type. The caller must
+/* gets the main apartment if it exists. The caller must
  * release the reference from the apartment as soon as the apartment pointer
  * is no longer required. */
-static APARTMENT *apartment_findfromtype(BOOL multi_threaded, BOOL main_apartment)
+static APARTMENT *apartment_findmain(void)
 {
-    APARTMENT *result = NULL;
-    struct apartment *apt;
+    APARTMENT *result;
 
     EnterCriticalSection(&csApartment);
 
-    if (!multi_threaded && main_apartment)
-    {
-        result = MainApartment;
-        if (result) apartment_addref(result);
-        LeaveCriticalSection(&csApartment);
-        return result;
-    }
+    result = MainApartment;
+    if (result) apartment_addref(result);
 
-    LIST_FOR_EACH_ENTRY( apt, &apts, struct apartment, entry )
-    {
-        if (apt->multi_threaded == multi_threaded)
-        {
-            result = apt;
-            apartment_addref(result);
-            break;
-        }
-    }
     LeaveCriticalSection(&csApartment);
 
     return result;
@@ -624,7 +609,7 @@ static HRESULT apartment_hostobject_in_hostapt(struct apartment *apt, BOOL multi
 
     if (!multi_threaded && main_apartment)
     {
-        APARTMENT *host_apt = apartment_findfromtype(FALSE, FALSE);
+        APARTMENT *host_apt = apartment_findmain();
         if (host_apt)
         {
             apartment_hwnd = apartment_getwindow(host_apt);
@@ -677,7 +662,7 @@ static HRESULT apartment_hostobject_in_hostapt(struct apartment *apt, BOOL multi
      * us to create the thread for the host apartment */
     if (!apartment_hwnd && !multi_threaded && main_apartment)
     {
-        APARTMENT *host_apt = apartment_findfromtype(FALSE, FALSE);
+        APARTMENT *host_apt = apartment_findmain();
         if (host_apt)
         {
             apartment_hwnd = apartment_getwindow(host_apt);




More information about the wine-cvs mailing list