Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/notes/bugfix-19541.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Fix clipboard ownership checks on windows causing private clipboard data to be cleared
14 changes: 10 additions & 4 deletions engine/src/w32-clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void MCWin32RawClipboardCommon::Clear()
if (m_item)
m_item->Release();
m_item = NULL;
CreateNewItem();
}

bool MCWin32RawClipboardCommon::IsExternalData() const
Expand Down Expand Up @@ -660,10 +661,15 @@ MCStringRef MCWin32RawClipboardCommon::CopyTypeForAtom(UINT p_atom)

bool MCWin32RawClipboard::IsOwned() const
{
// Get the IDataObject that we are placing onto the clipboard
IDataObject* t_data_object = NULL;
if (m_item != NULL)
t_data_object = m_item->GetIDataObject();

// Check if our data object is the current clipboard data object
if (m_item == NULL)
return false;
return S_OK == OleIsCurrentClipboard(m_item->GetIDataObject());
if (t_data_object == NULL)
return true;
return S_OK == OleIsCurrentClipboard(t_data_object);
}


Expand Down Expand Up @@ -694,7 +700,7 @@ bool MCWin32RawClipboard::PushUpdates()
bool MCWin32RawClipboard::PullUpdates()
{
// If we're still the owner of the clipboard, do nothing
if (IsOwned())
if (m_item != NULL && IsOwned())
return true;

// Release the current clipboard contents
Expand Down