ole32: When CoLockObjectExternal with fLock=TRUE is used on an object

that hasn't yet been marshaled then it should create a new stub
manager.
This commit is contained in:
Robert Shearman 2006-06-30 11:07:43 +01:00 committed by Alexandre Julliard
parent 2fa3cc03a5
commit 628371021b
2 changed files with 35 additions and 1 deletions

View File

@ -2098,6 +2098,10 @@ static void COM_RevokeAllClasses()
* RETURNS
* Success: S_OK.
* Failure: HRESULT code.
*
* NOTES
* If fLock is TRUE and an object is passed in that doesn't have a stub
* manager then a new stub manager is created for the object.
*/
HRESULT WINAPI CoLockObjectExternal(
LPUNKNOWN pUnk,
@ -2126,6 +2130,18 @@ HRESULT WINAPI CoLockObjectExternal(
return S_OK;
}
else if (fLock)
{
stubmgr = new_stub_manager(apt, pUnk);
if (stubmgr)
{
stub_manager_ext_addref(stubmgr, 1);
stub_manager_int_release(stubmgr);
}
return S_OK;
}
else
{
WARN("stub object not found %p\n", pUnk);

View File

@ -998,6 +998,20 @@ static void test_lock_object_external(void)
cLocks = 0;
/* test the stub manager creation aspect of CoLockObjectExternal when the
* object hasn't been marshaled yet */
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
ok_more_than_one_lock();
CoDisconnectObject((IUnknown*)&Test_ClassFactory, 0);
ok_no_locks();
/* test our empty stub manager being handled correctly in
* CoMarshalInterface */
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, TRUE, TRUE);
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
ok_ole_success(hr, CreateStreamOnHGlobal);
hr = CoMarshalInterface(pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
@ -1016,6 +1030,10 @@ static void test_lock_object_external(void)
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, TRUE);
ok_more_than_one_lock();
CoLockObjectExternal((IUnknown*)&Test_ClassFactory, FALSE, TRUE);
ok_no_locks();
}