Commit c3fff833 authored by Martin's avatar Martin 💬
Browse files

Clipboard: fix trailing null issue for gtk2. Issue #21453

git-svn-id: trunk@58530 -
parent 0b86f592
......@@ -438,6 +438,7 @@ end;
procedure TClipboard.SetAsText(const Value: string);
var s: string;
i: Integer;
begin
//DebugLn('[TClipboard.SetAsText] A ',ClipboardTypeName[ClipboardType],' "',Value,'"');
if Assigned(FOnRequest) then exit;
......@@ -446,7 +447,10 @@ begin
else
s:=#0;
Clear;
SetBuffer(PredefinedClipboardFormat(pcfText),s[1],length(Value)+1);
i := Length(Value);
if ClipboardFormatNeedsNullByte(pcfText) then
i := i + 1;
SetBuffer(PredefinedClipboardFormat(pcfText),s[1],i);
//DebugLn('[TClipboard.SetAsText] END ',ClipboardTypeName[ClipboardType],' "',Value,'"');
end;
......
......@@ -90,6 +90,12 @@ begin
Result := 0;
end;
function TWidgetSet.ClipboardFormatNeedsNullByte(
const AFormat: TPredefinedClipboardFormat): Boolean;
begin
Result := AFormat = pcfText;
end;
//todo: remove ?
function TWidgetSet.CreateEmptyRegion: hRGN;
begin
......
......@@ -91,6 +91,11 @@ begin
Result := WidgetSet.ClipboardRegisterFormat(AMimeType);
end;
function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean;
begin
Result := WidgetSet.ClipboardFormatNeedsNullByte(AFormat);
end;
function CreateEmptyRegion: hRGN;
begin
Result := WidgetSet.CreateEmptyRegion;
......
......@@ -48,6 +48,7 @@ function ClipboardGetOwnerShip(ClipboardType: TClipboardType;
OnRequestProc: TClipboardRequestEvent; FormatCount: integer;
Formats: PClipboardFormat): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function CreateEmptyRegion: hRGN; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function CreatePixmapIndirect(const Data: Pointer; const TransColor: Longint): HBITMAP; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function CreateRegionCopy(SrcRGN: hRGN): hRGN; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
......
......@@ -720,6 +720,12 @@ begin
Result:=true;
end;
function TGtk2WidgetSet.ClipboardFormatNeedsNullByte(
const AFormat: TPredefinedClipboardFormat): Boolean;
begin
Result := False;
end;
{------------------------------------------------------------------------------
Function: ClipboardRegisterFormat
Params: AMimeType
......
......@@ -47,6 +47,7 @@ function ClipboardGetFormats(ClipboardType: TClipboardType;
function ClipboardGetOwnerShip(ClipboardType: TClipboardType;
OnRequestProc: TClipboardRequestEvent; FormatCount: integer;
Formats: PClipboardFormat): boolean; override;
function ClipboardFormatNeedsNullByte(const AFormat: TPredefinedClipboardFormat): Boolean; override;
function ClipboardRegisterFormat(const AMimeType: string): TClipboardFormat; override;
function CombineRgn(Dest, Src1, Src2 : HRGN; fnCombineMode : Longint) : Longint; override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment