From 14056f155e685fcc7dc06e6068e070e07174b747 Mon Sep 17 00:00:00 2001
From: ROOL <code@riscosopen.org>
Date: Mon, 30 Dec 2019 14:51:37 +0000
Subject: [PATCH] Fix for abort on pasting into writeable menus

Detail:
  Menu windows don't store the task handle in their datablock, so an incorrect one was used as part of the data transfer sequence.
  Also, minor fix for Message_ClaimEntity when bit 2 was clear (bits 0,1 set). The response meant that, for example, Alt-click to rename, select text in writeable and press ^C - copied to clipboard, but writeable is removed.
Admin:
  Submission for Clipboard Support bounty.
---
 s/CBTask | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/s/CBTask b/s/CBTask
index 2790d0f..000046d 100644
--- a/s/CBTask
+++ b/s/CBTask
@@ -251,6 +251,10 @@ cbtask_claimentity_rx
         LDR     R2,[R2]
         TEQ     R0,R2
         BEQ     cbtask_poll             ; it was us, so ignore
+        ; was it a clipboard claim?
+        LDR     R0,[R1,#msClaimEntity_flags]
+        TST     R0,#4
+        BEQ     cbtask_poll
         ; release our claim
         MOV     R0,#clipboard_flexblock_clipdata
         MOV     R1,#0
@@ -866,6 +870,8 @@ cbtask_get_icon_text
         ADRL    R2,clipboard_taskhandle
         LDR     R2,[R2]                 ; destination task (us)
         LDR     R0,[R10,#w_taskhandle]
+        CMP     R0,#-1                  ; menu windows don't have a task handle attached
+        LDREQ   R0,menutaskhandle       ; so we get the menu owner's handle to use instead
         LDR     R14,[wsptr,R0]
         LDR     R14,[R14,#task_flagword]
         MOV     R14,R14,LSR #flag_versionbit
@@ -897,6 +903,8 @@ cbtask_put_icon_text
         LDR     R0,[R0]
 
         LDR     R2,[R10,#w_taskhandle]
+        CMP     R2,#-1                  ; menu windows don't have an attached taskhandle
+        LDREQ   R2,menutaskhandle       ; so look at the menu's owner instead
         LDR     R14,[wsptr,R2]
         LDR     R14,[R14,#task_flagword]
         MOV     R14,R14,LSR #flag_versionbit
-- 
GitLab