- Add code for destroying the thread-local storage data, but don't use
authorRobert Shearman <rob@codeweavers.com>
Tue, 1 Feb 2005 14:18:10 +0000 (14:18 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 1 Feb 2005 14:18:10 +0000 (14:18 +0000)
  it yet.
- Don't release apartment on changing modes because we didn't add a
  reference anywhere.
- Quieten the RPC_E_DISCONNECTED error message as it is an expected
  return code.
- Treat IID_NULL the same as IID_IUnknown.
- Make tests compile on Win95 again.
- Fix copy+paste error where the test failure should be from the
  CoUnmarshalInterface function.

dlls/ole32/compobj.c
dlls/ole32/marshal.c
dlls/ole32/ole32_main.h
dlls/ole32/tests/marshal.c

index d391ef9ea7a31028ac2338c31d018d5a6fec1809..5bc139626b8b399de65731ee988df2f06cd4e69e 100644 (file)
@@ -202,6 +202,19 @@ void COMPOBJ_UninitProcess( void )
     UnregisterClassA(aptWinClass, OLE32_hInstance);
 }
 
+void COM_TlsDestroy()
+{
+    struct oletls *info = NtCurrentTeb()->ReservedForOle;
+    if (info)
+    {
+        if (info->apt) COM_ApartmentRelease(info->apt);
+        if (info->errorinfo) IErrorInfo_Release(info->errorinfo);
+        if (info->state) IUnknown_Release(info->state);
+        HeapFree(GetProcessHeap(), 0, info);
+        NtCurrentTeb()->ReservedForOle = NULL;
+    }
+}
+
 /******************************************************************************
  * Manage apartments.
  */
@@ -585,7 +598,6 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
     /* Changing the threading model after it's been set is illegal. If this warning is triggered by Wine
        code then we are probably using the wrong threading model to implement that API. */
     ERR("Attempt to change threading model of this apartment from 0x%lx to 0x%lx\n", apt->model, dwCoInit);
-    COM_ApartmentRelease(apt);
     return RPC_E_CHANGED_MODE;
   }
   else
index 0dbbfbf67de490b8ac90e77feeb25896db9c4962..a78f0b6cf740d2089e479d545aa14beb510aff40 100644 (file)
@@ -363,6 +363,11 @@ static HRESULT ifproxy_release_public_refs(struct ifproxy * This)
             hr = IRemUnknown_RemRelease(remunk, 1, &rif);
             if (hr == S_OK)
                 This->refs = 0;
+            else if (hr == RPC_E_DISCONNECTED)
+                WARN("couldn't release references because object was "
+                     "disconnected: oxid = %s, oid = %s\n",
+                     wine_dbgstr_longlong(This->parent->oxid),
+                     wine_dbgstr_longlong(This->parent->oid));
             else
                 ERR("IRemUnknown_RemRelease failed with error 0x%08lx\n", hr);
         }
@@ -490,8 +495,11 @@ static HRESULT proxy_manager_create_ifproxy(
     ifproxy->proxy = NULL;
 
     /* the IUnknown interface is special because it does not have a
-     * proxy associated with the ifproxy as we handle IUnknown ourselves */
-    if (IsEqualIID(riid, &IID_IUnknown))
+     * proxy associated with the ifproxy as we handle IUnknown ourselves.
+     * IID_NULL is a placeholder for IID_IUnknown used by the DCOM part of
+     * the rpc runtime. */
+    if (IsEqualIID(riid, &IID_NULL) ||
+        IsEqualIID(riid, &IID_IUnknown))
     {
         ifproxy->iface = (void *)&This->lpVtbl;
         hr = S_OK;
index f488b07fe50414cb0ba70bce31545af1325abdb4..0471974368777b347617b6916fd65cde137aa1ae 100644 (file)
@@ -29,5 +29,6 @@ extern HINSTANCE OLE32_hInstance;
 
 void COMPOBJ_InitProcess( void );
 void COMPOBJ_UninitProcess( void );
+void COM_TlsDestroy( void );
 
 #endif /* __WINE_OLE32_MAIN_H */
index 08a839c4e15eabb3524aaee77f50df5e5a81b320..0a8d3c25f1f1ed7b0ce7243751cc8c03fc6b8b49 100644 (file)
@@ -188,7 +188,7 @@ static DWORD CALLBACK host_object_proc(LPVOID p)
     HRESULT hr;
     MSG msg;
 
-    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 
     if (data->filter)
     {
@@ -436,7 +436,7 @@ static void test_marshal_stub_apartment_shutdown()
     
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
     IStream_Release(pStream);
 
     ok_more_than_one_lock();
@@ -469,7 +469,7 @@ static void test_marshal_proxy_apartment_shutdown()
     
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
     IStream_Release(pStream);
 
     ok_more_than_one_lock();
@@ -484,7 +484,7 @@ static void test_marshal_proxy_apartment_shutdown()
 
     end_host_object(tid, thread);
 
-    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 }
 
 /* tests that proxies are released when the containing mta apartment is destroyed */
@@ -509,7 +509,7 @@ static void test_marshal_proxy_mta_apartment_shutdown()
        
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
     IStream_Release(pStream);
 
     ok_more_than_one_lock();
@@ -619,7 +619,7 @@ static void test_tableweak_marshal_and_unmarshal_twice()
 
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
 
     ok_more_than_one_lock();
 
@@ -750,7 +750,7 @@ static void test_tablestrong_marshal_and_unmarshal_twice()
 
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy1);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
 
     ok_more_than_one_lock();
 
@@ -947,7 +947,7 @@ static void test_proxy_used_in_wrong_thread()
     
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IClassFactory, (void **)&pProxy);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
     IStream_Release(pStream);
 
     ok_more_than_one_lock();
@@ -1139,7 +1139,7 @@ static void test_proxy_interfaces()
        
     IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
     hr = CoUnmarshalInterface(pStream, &IID_IUnknown, (void **)&pProxy);
-    ok_ole_success(hr, CoReleaseMarshalData);
+    ok_ole_success(hr, CoUnmarshalInterface);
     IStream_Release(pStream);
 
     ok_more_than_one_lock();