Huw Davies : ole32: Call the appropriate storage function when we run the object.
Alexandre Julliard
julliard at winehq.org
Thu Oct 23 08:38:10 CDT 2008
Module: wine
Branch: master
Commit: 92202feff3c46585c552cc439c5584074cf58a1b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=92202feff3c46585c552cc439c5584074cf58a1b
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Oct 23 10:25:24 2008 +0100
ole32: Call the appropriate storage function when we run the object.
---
dlls/ole32/defaulthandler.c | 51 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/dlls/ole32/defaulthandler.c b/dlls/ole32/defaulthandler.c
index ce44aec..49bb733 100644
--- a/dlls/ole32/defaulthandler.c
+++ b/dlls/ole32/defaulthandler.c
@@ -64,6 +64,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
+enum storage_state
+{
+ storage_state_uninitialised,
+ storage_state_initialised,
+ storage_state_loaded
+};
+
/****************************************************************************
* DefaultHandler
*
@@ -119,6 +126,10 @@ struct DefaultHandler
/* connection cookie for the advise on the delegate OLE object */
DWORD dwAdvConn;
+
+ /* storage passed to Load or InitNew */
+ IStorage *storage;
+ enum storage_state storage_state;
};
typedef struct DefaultHandler DefaultHandler;
@@ -1302,7 +1313,12 @@ static HRESULT WINAPI DefaultHandler_Run(
IOleObject_QueryInterface(This->pOleDelegate, &IID_IPersistStorage,
(void **)&This->pPSDelegate);
if (This->pPSDelegate)
- hr = IPersistStorage_InitNew(This->pPSDelegate, NULL);
+ {
+ if(This->storage_state == storage_state_initialised)
+ hr = IPersistStorage_InitNew(This->pPSDelegate, This->storage);
+ else if(This->storage_state == storage_state_loaded)
+ hr = IPersistStorage_Load(This->pPSDelegate, This->storage);
+ }
}
if (SUCCEEDED(hr) && This->containerApp)
@@ -1548,6 +1564,13 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_InitNew(
if(SUCCEEDED(hr) && object_is_running(This))
hr = IPersistStorage_InitNew(This->pPSDelegate, pStg);
+ if(SUCCEEDED(hr))
+ {
+ IStorage_AddRef(pStg);
+ This->storage = pStg;
+ This->storage_state = storage_state_initialised;
+ }
+
return hr;
}
@@ -1570,6 +1593,12 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_Load(
if(SUCCEEDED(hr) && object_is_running(This))
hr = IPersistStorage_Load(This->pPSDelegate, pStg);
+ if(SUCCEEDED(hr))
+ {
+ IStorage_AddRef(pStg);
+ This->storage = pStg;
+ This->storage_state = storage_state_loaded;
+ }
return hr;
}
@@ -1614,6 +1643,14 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_SaveCompleted(
if(SUCCEEDED(hr) && object_is_running(This))
hr = IPersistStorage_SaveCompleted(This->pPSDelegate, pStgNew);
+ if(pStgNew)
+ {
+ IStorage_AddRef(pStgNew);
+ if(This->storage) IStorage_Release(This->storage);
+ This->storage = pStgNew;
+ This->storage_state = storage_state_loaded;
+ }
+
return hr;
}
@@ -1635,6 +1672,10 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_HandsOffStorage(
if(SUCCEEDED(hr) && object_is_running(This))
hr = IPersistStorage_HandsOffStorage(This->pPSDelegate);
+ if(This->storage) IStorage_Release(This->storage);
+ This->storage = NULL;
+ This->storage_state = storage_state_uninitialised;
+
return hr;
}
@@ -1795,6 +1836,8 @@ static DefaultHandler* DefaultHandler_Construct(
This->pDataDelegate = NULL;
This->dwAdvConn = 0;
+ This->storage = NULL;
+ This->storage_state = storage_state_uninitialised;
return This;
}
@@ -1836,6 +1879,12 @@ static void DefaultHandler_Destroy(
This->dataAdviseHolder = NULL;
}
+ if (This->storage)
+ {
+ IStorage_Release(This->storage);
+ This->storage = NULL;
+ }
+
HeapFree(GetProcessHeap(), 0, This);
}
More information about the wine-cvs
mailing list