MSHTML: Call LockContainer only if it's not already locked/unlocked

Jacek Caban jack at itma.pwr.wroc.pl
Mon Aug 22 08:09:54 CDT 2005


HTMLDocument_LockContainer is not static because it'll
be used in the other file in the next patch.

Changelog:
    - Call LockContainer only if it's not already locked/unlocked
    - Only return S_OK in SetClientSite if IOleClientSite is not changed
-------------- next part --------------
Index: dlls/mshtml/mshtml_private.h
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/mshtml_private.h,v
retrieving revision 1.24
diff -u -p -r1.24 mshtml_private.h
--- dlls/mshtml/mshtml_private.h	15 Aug 2005 09:41:30 -0000	1.24
+++ dlls/mshtml/mshtml_private.h	22 Aug 2005 11:02:57 -0000
@@ -66,6 +66,7 @@ typedef struct {
     BOOL ui_active;
     BOOL window_active;
     BOOL has_key_path;
+    BOOL container_locked;
 
     BindStatusCallback *status_callback;
 } HTMLDocument;
@@ -110,6 +111,8 @@ void HTMLDocument_Service_Init(HTMLDocum
 void HTMLDocument_NSContainer_Init(HTMLDocument*);
 
 void HTMLDocument_NSContainer_Destroy(HTMLDocument*);
+
+void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
 
 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
 
Index: dlls/mshtml/oleobj.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/oleobj.c,v
retrieving revision 1.17
diff -u -p -r1.17 oleobj.c
--- dlls/mshtml/oleobj.c	22 Aug 2005 09:25:20 -0000	1.17
+++ dlls/mshtml/oleobj.c	22 Aug 2005 11:02:58 -0000
@@ -70,6 +70,9 @@ static HRESULT WINAPI OleObject_SetClien
 
     TRACE("(%p)->(%p)\n", This, pClientSite);
 
+    if(pClientSite == This->client)
+        return S_OK;
+
     if(This->client)
         IOleClientSite_Release(This->client);
 
@@ -190,7 +193,6 @@ static HRESULT WINAPI OleObject_SetHostN
 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
 {
     HTMLDocument *This = OLEOBJ_THIS(iface);
-    HRESULT hres;
 
     TRACE("(%p)->(%08lx)\n", This, dwSaveOption);
 
@@ -200,14 +202,7 @@ static HRESULT WINAPI OleObject_Close(IO
     if(This->in_place_active)
         IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
 
-    if(This->client) {
-        IOleContainer *container;
-        hres = IOleClientSite_GetContainer(This->client, &container);
-        if(SUCCEEDED(hres)) {
-            IOleContainer_LockContainer(container, FALSE);
-            IOleContainer_Release(container);
-        }
-    }
+    HTMLDocument_LockContainer(This, FALSE);
     
     return S_OK;
 }
@@ -260,12 +255,8 @@ static HRESULT WINAPI OleObject_DoVerb(I
 
     hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
     if(SUCCEEDED(hres)) {
-        IOleContainer *pContainer;
-        hres = IOleClientSite_GetContainer(pActiveSite, &pContainer);
-        if(SUCCEEDED(hres)) {
-            IOleContainer_LockContainer(pContainer, TRUE);
-            IOleContainer_Release(pContainer);
-        }
+        HTMLDocument_LockContainer(This, TRUE);
+
         /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
         hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
         IOleDocumentSite_Release(pDocSite);
@@ -1003,6 +994,22 @@ static const IOleControlVtbl OleControlV
     OleControl_FreezeEvents
 };
 
+void HTMLDocument_LockContainer(HTMLDocument *This, BOOL fLock)
+{
+    IOleContainer *container;
+    HRESULT hres;
+
+    if(!This->client || This->container_locked == fLock)
+        return;
+
+    hres = IOleClientSite_GetContainer(This->client, &container);
+    if(SUCCEEDED(hres)) {
+        IOleContainer_LockContainer(container, fLock);
+        This->container_locked = fLock;
+        IOleContainer_Release(container);
+    }
+}
+
 void HTMLDocument_OleObj_Init(HTMLDocument *This)
 {
     This->lpOleObjectVtbl = &OleObjectVtbl;
@@ -1014,4 +1021,5 @@ void HTMLDocument_OleObj_Init(HTMLDocume
     This->hostui = NULL;
 
     This->has_key_path = FALSE;
+    This->container_locked = FALSE;
 }


More information about the wine-patches mailing list