Skip to content

Commit 40579d7

Browse files
[[ RawClipboard ]] Fix various refcounting bugs
1 parent fda3629 commit 40579d7

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

engine/src/clipboard.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ MCClipboard::~MCClipboard()
6262
MCValueRelease(m_private_data);
6363
}
6464

65-
bool MCClipboard::Lock() const
65+
bool MCClipboard::Lock(bool p_skip_pull) const
6666
{
6767
// Increase the lock count. If it moves from zero to one, update the
6868
// contents of this clipboard.
6969
//
7070
// TODO: atomic operations
71-
if (m_lock_count++ == 0)
71+
if (m_lock_count++ == 0 && !p_skip_pull)
7272
{
7373
return PullUpdates();
7474
}
@@ -1152,7 +1152,7 @@ MCClipboard* MCClipboard::CreateSystemDragboard()
11521152
{
11531153
// Drag boards are created in a locked state
11541154
MCClipboard* t_dragboard = new MCClipboard(MCRawClipboard::CreateSystemDragboard());
1155-
t_dragboard->Lock();
1155+
t_dragboard->Lock(true);
11561156
t_dragboard->Clear();
11571157
return t_dragboard;
11581158
}

engine/src/clipboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MCClipboard :
4040
// For efficiency, a clipboard used as a drag board should be permanently
4141
// locked as this inhibits automatic updates. (The contents of the drag
4242
// board are only meaningful during a drag-and-drop operation).
43-
bool Lock() const;
43+
bool Lock(bool p_skip_pull = false) const;
4444
bool Unlock() const;
4545

4646
// Clears the contents of this clipboard.

engine/src/desktop.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ void MCPlatformHandleDragLeave(MCPlatformWindowRef p_window)
546546
// On some platforms (Mac and iOS), the drag board used for drag-and-drop
547547
// operations may not be the main drag board. Reset the drag board back to
548548
// the main one after the drag has left.
549-
MCdragboard->Rebind(MCRawClipboard::CreateSystemDragboard());
549+
MCAutoRefcounted<MCRawClipboard> t_dragboard(MCRawClipboard::CreateSystemDragboard());
550+
MCdragboard->Rebind(t_dragboard);
550551

551552
MCdispatcher -> wmdragleave(p_window);
552553
}

engine/src/filedefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2020
#ifndef FILEDEFS_H
2121
#define FILEDEFS_H
2222

23+
#include "typedefs.h"
24+
2325
#define SIGNATURE "# MetaCard "
2426

2527
#define READ_PIPE_SIZE 16384

0 commit comments

Comments
 (0)