View Issue Details

IDProjectCategoryView StatusLast Update
0035984LazarusWidgetsetpublic2019-08-20 17:07
ReporterZoë PetersonAssigned ToDmitry Boyarintsev 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0.4Product Build 
Target VersionFixed in Version 
Summary0035984: Clipboard.SetAsText includes an extra #0 character
DescriptionWhen using Clipboard.AsText to copy text to the Cocoa clipboard, an extra invalid #0 character is inserted at the end. You can see the behavior by selecting and copying text in SynEdit then pasting in Xcode. If you paste in the middle of a comment it will break syntax highlighting, and pressing delete will seem to pause for one delete keystroke since it's deleting the invisible #0 character. Copying/pasting within an LCL application won't show the issue since GetAsText silently strips a trailing #0 if one exists.

Patch attached that disables the (LCL) behavior for the Cocoa widgetset
TagsNo tags attached.
Fixed in Revision61731
LazTarget-
WidgetsetCocoa
Attached Files
  • cocoa-clipboard.patch (1,216 bytes)
    --- a/lcl/interfaces/cocoa/cocoawinapi.inc
    +++ b/lcl/interfaces/cocoa/cocoawinapi.inc
    @@ -254,6 +254,12 @@ begin
       {$ENDIF}
     end;
     
    +function TCocoaWidgetSet.ClipboardFormatNeedsNullByte(
    +  const AFormat: TPredefinedClipboardFormat): Boolean;
    +begin
    +  Result := False
    +end;
    +
     function TCocoaWidgetSet.CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;
     begin
       Result := LCLType.Error;
    diff --git a/lcl/interfaces/cocoa/cocoawinapih.inc b/lcl/interfaces/cocoa/cocoawinapih.inc
    index 46b141bb6a..f16cac1ba9 100644
    --- a/lcl/interfaces/cocoa/cocoawinapih.inc
    +++ b/lcl/interfaces/cocoa/cocoawinapih.inc
    @@ -42,6 +42,7 @@ function ClipboardGetOwnerShip(ClipboardType: TClipboardType;
       OnRequestProc: TClipboardRequestEvent;  FormatCount: integer;
       Formats: PClipboardFormat): boolean; override;
     function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; override;
    +function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean; override;
     
     function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;  override;
     function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
    
    cocoa-clipboard.patch (1,216 bytes)

Relationships

related to 0021453 resolvedMartin Friebe Remove trailing zero when copying to clipboard (gtk2) 

Activities

Zoë Peterson

2019-08-19 22:43

reporter  

cocoa-clipboard.patch (1,216 bytes)
--- a/lcl/interfaces/cocoa/cocoawinapi.inc
+++ b/lcl/interfaces/cocoa/cocoawinapi.inc
@@ -254,6 +254,12 @@ begin
   {$ENDIF}
 end;
 
+function TCocoaWidgetSet.ClipboardFormatNeedsNullByte(
+  const AFormat: TPredefinedClipboardFormat): Boolean;
+begin
+  Result := False
+end;
+
 function TCocoaWidgetSet.CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;
 begin
   Result := LCLType.Error;
diff --git a/lcl/interfaces/cocoa/cocoawinapih.inc b/lcl/interfaces/cocoa/cocoawinapih.inc
index 46b141bb6a..f16cac1ba9 100644
--- a/lcl/interfaces/cocoa/cocoawinapih.inc
+++ b/lcl/interfaces/cocoa/cocoawinapih.inc
@@ -42,6 +42,7 @@ function ClipboardGetOwnerShip(ClipboardType: TClipboardType;
   OnRequestProc: TClipboardRequestEvent;  FormatCount: integer;
   Formats: PClipboardFormat): boolean; override;
 function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; override;
+function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean; override;
 
 function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint;  override;
 function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
cocoa-clipboard.patch (1,216 bytes)

Dmitry Boyarintsev

2019-08-20 17:07

developer   ~0117745

thanks for the patch. applied.
please test and close if ok

Issue History

Date Modified Username Field Change
2019-08-19 22:43 Zoë Peterson New Issue
2019-08-19 22:43 Zoë Peterson File Added: cocoa-clipboard.patch
2019-08-20 17:04 Dmitry Boyarintsev Relationship added related to 0021453
2019-08-20 17:07 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-08-20 17:07 Dmitry Boyarintsev Status new => resolved
2019-08-20 17:07 Dmitry Boyarintsev Resolution open => fixed
2019-08-20 17:07 Dmitry Boyarintsev Fixed in Revision => 61731
2019-08-20 17:07 Dmitry Boyarintsev LazTarget => -
2019-08-20 17:07 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-08-20 17:07 Dmitry Boyarintsev Note Added: 0117745