Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a37e470

Browse files
Merge pull request #5451 from montegoulding/bugfix-19541
[Bug 19541] Improve clipboard owner check on win
2 parents 79cc7fe + 5499ad2 commit a37e470

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

docs/notes/bugfix-19541.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix clipboard ownership checks on windows causing private clipboard data to be cleared

engine/src/w32-clipboard.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ void MCWin32RawClipboardCommon::Clear()
149149
if (m_item)
150150
m_item->Release();
151151
m_item = NULL;
152+
CreateNewItem();
152153
}
153154

154155
bool MCWin32RawClipboardCommon::IsExternalData() const
@@ -660,10 +661,15 @@ MCStringRef MCWin32RawClipboardCommon::CopyTypeForAtom(UINT p_atom)
660661

661662
bool MCWin32RawClipboard::IsOwned() const
662663
{
664+
// Get the IDataObject that we are placing onto the clipboard
665+
IDataObject* t_data_object = NULL;
666+
if (m_item != NULL)
667+
t_data_object = m_item->GetIDataObject();
668+
663669
// Check if our data object is the current clipboard data object
664-
if (m_item == NULL)
665-
return false;
666-
return S_OK == OleIsCurrentClipboard(m_item->GetIDataObject());
670+
if (t_data_object == NULL)
671+
return true;
672+
return S_OK == OleIsCurrentClipboard(t_data_object);
667673
}
668674

669675

@@ -694,7 +700,7 @@ bool MCWin32RawClipboard::PushUpdates()
694700
bool MCWin32RawClipboard::PullUpdates()
695701
{
696702
// If we're still the owner of the clipboard, do nothing
697-
if (IsOwned())
703+
if (m_item != NULL && IsOwned())
698704
return true;
699705

700706
// Release the current clipboard contents

0 commit comments

Comments
 (0)