ole32: OleFlushClipboard shouldn't call EmptyClipboard.
This commit is contained in:
parent
524a99a2da
commit
b7a2e83ddb
|
@ -1474,13 +1474,9 @@ HRESULT WINAPI OleFlushClipboard(void)
|
||||||
FORMATETC rgelt;
|
FORMATETC rgelt;
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
BOOL bClipboardOpen = FALSE;
|
BOOL bClipboardOpen = FALSE;
|
||||||
IDataObject* pIDataObjectSrc = NULL;
|
|
||||||
|
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure we have a clipboard object
|
|
||||||
*/
|
|
||||||
OLEClipbrd_Initialize();
|
OLEClipbrd_Initialize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1489,30 +1485,14 @@ HRESULT WINAPI OleFlushClipboard(void)
|
||||||
if (!theOleClipboard->pIDataObjectSrc)
|
if (!theOleClipboard->pIDataObjectSrc)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
/*
|
|
||||||
* Addref and save the source data object we are holding on to temporarily,
|
|
||||||
* since it will be released when we empty the clipboard.
|
|
||||||
*/
|
|
||||||
pIDataObjectSrc = theOleClipboard->pIDataObjectSrc;
|
|
||||||
IDataObject_AddRef(pIDataObjectSrc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open the Windows clipboard
|
|
||||||
*/
|
|
||||||
if ( !(bClipboardOpen = OpenClipboard(theOleClipboard->hWndClipboard)) )
|
if ( !(bClipboardOpen = OpenClipboard(theOleClipboard->hWndClipboard)) )
|
||||||
HANDLE_ERROR( CLIPBRD_E_CANT_OPEN );
|
HANDLE_ERROR( CLIPBRD_E_CANT_OPEN );
|
||||||
|
|
||||||
/*
|
|
||||||
* Empty the current clipboard
|
|
||||||
*/
|
|
||||||
if ( !EmptyClipboard() )
|
|
||||||
HANDLE_ERROR( CLIPBRD_E_CANT_EMPTY );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Render all HGLOBAL formats supported by the source into
|
* Render all HGLOBAL formats supported by the source into
|
||||||
* the windows clipboard.
|
* the windows clipboard.
|
||||||
*/
|
*/
|
||||||
if ( FAILED( hr = IDataObject_EnumFormatEtc( pIDataObjectSrc,
|
if ( FAILED( hr = IDataObject_EnumFormatEtc( theOleClipboard->pIDataObjectSrc,
|
||||||
DATADIR_GET,
|
DATADIR_GET,
|
||||||
&penumFormatetc) ))
|
&penumFormatetc) ))
|
||||||
{
|
{
|
||||||
|
@ -1528,10 +1508,7 @@ HRESULT WINAPI OleFlushClipboard(void)
|
||||||
GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1)
|
GetClipboardFormatNameA(rgelt.cfFormat, szFmtName, sizeof(szFmtName)-1)
|
||||||
? szFmtName : "");
|
? szFmtName : "");
|
||||||
|
|
||||||
/*
|
if ( FAILED(OLEClipbrd_RenderFormat( theOleClipboard->pIDataObjectSrc, &rgelt )) )
|
||||||
* Render the clipboard data
|
|
||||||
*/
|
|
||||||
if ( FAILED(OLEClipbrd_RenderFormat( pIDataObjectSrc, &rgelt )) )
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1540,16 +1517,11 @@ HRESULT WINAPI OleFlushClipboard(void)
|
||||||
|
|
||||||
hr = set_dataobject_format(NULL);
|
hr = set_dataobject_format(NULL);
|
||||||
|
|
||||||
/*
|
IDataObject_Release(theOleClipboard->pIDataObjectSrc);
|
||||||
* Release the source data object we are holding on to
|
theOleClipboard->pIDataObjectSrc = NULL;
|
||||||
*/
|
|
||||||
IDataObject_Release(pIDataObjectSrc);
|
|
||||||
|
|
||||||
CLEANUP:
|
CLEANUP:
|
||||||
|
|
||||||
/*
|
|
||||||
* Close Windows clipboard (It remains associated with our window)
|
|
||||||
*/
|
|
||||||
if ( bClipboardOpen && !CloseClipboard() )
|
if ( bClipboardOpen && !CloseClipboard() )
|
||||||
hr = CLIPBRD_E_CANT_CLOSE;
|
hr = CLIPBRD_E_CANT_CLOSE;
|
||||||
|
|
||||||
|
|
|
@ -625,6 +625,7 @@ static void test_set_clipboard(void)
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
LPDATAOBJECT data1, data2, data_cmpl;
|
LPDATAOBJECT data1, data2, data_cmpl;
|
||||||
|
HGLOBAL hblob, h;
|
||||||
|
|
||||||
cf_stream = RegisterClipboardFormatA("stream format");
|
cf_stream = RegisterClipboardFormatA("stream format");
|
||||||
cf_storage = RegisterClipboardFormatA("storage format");
|
cf_storage = RegisterClipboardFormatA("storage format");
|
||||||
|
@ -681,6 +682,16 @@ static void test_set_clipboard(void)
|
||||||
hr = OleIsCurrentClipboard(NULL);
|
hr = OleIsCurrentClipboard(NULL);
|
||||||
ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr);
|
ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr);
|
||||||
|
|
||||||
|
/* put a format directly onto the clipboard to show
|
||||||
|
OleFlushClipboard doesn't empty the clipboard */
|
||||||
|
hblob = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE|GMEM_ZEROINIT, 10);
|
||||||
|
OpenClipboard(NULL);
|
||||||
|
h = SetClipboardData(cf_onemore, hblob);
|
||||||
|
ok(h == hblob, "got %p\n", h);
|
||||||
|
h = GetClipboardData(cf_onemore);
|
||||||
|
ok(h == hblob, "got %p\n", h);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
hr = OleFlushClipboard();
|
hr = OleFlushClipboard();
|
||||||
ok(hr == S_OK, "failed to flush clipboard, hr = 0x%08x\n", hr);
|
ok(hr == S_OK, "failed to flush clipboard, hr = 0x%08x\n", hr);
|
||||||
hr = OleIsCurrentClipboard(data1);
|
hr = OleIsCurrentClipboard(data1);
|
||||||
|
@ -690,10 +701,21 @@ static void test_set_clipboard(void)
|
||||||
hr = OleIsCurrentClipboard(NULL);
|
hr = OleIsCurrentClipboard(NULL);
|
||||||
ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr);
|
ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr);
|
||||||
|
|
||||||
|
/* format should survive the flush */
|
||||||
|
OpenClipboard(NULL);
|
||||||
|
h = GetClipboardData(cf_onemore);
|
||||||
|
ok(h == hblob, "got %p\n", h);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
test_cf_dataobject(NULL);
|
test_cf_dataobject(NULL);
|
||||||
|
|
||||||
ok(OleSetClipboard(NULL) == S_OK, "failed to clear clipboard, hr = 0x%08x\n", hr);
|
ok(OleSetClipboard(NULL) == S_OK, "failed to clear clipboard, hr = 0x%08x\n", hr);
|
||||||
|
|
||||||
|
OpenClipboard(NULL);
|
||||||
|
h = GetClipboardData(cf_onemore);
|
||||||
|
ok(h == NULL, "got %p\n", h);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
hr = OleSetClipboard(data_cmpl);
|
hr = OleSetClipboard(data_cmpl);
|
||||||
ok(hr == S_OK, "failed to set clipboard to complex data, hr = 0x%08x\n", hr);
|
ok(hr == S_OK, "failed to set clipboard to complex data, hr = 0x%08x\n", hr);
|
||||||
test_cf_dataobject(data_cmpl);
|
test_cf_dataobject(data_cmpl);
|
||||||
|
|
Loading…
Reference in New Issue