Designer: Prevent copying/cutting TCustomTabControl and TCustomPage. Can lead to halt or crash.

git-svn-id: trunk@51950 -
This commit is contained in:
juha 2016-03-15 11:22:28 +00:00
parent 2ac2eea1d5
commit 4b11aaff8c
2 changed files with 16 additions and 1 deletions

View File

@ -39,7 +39,7 @@ interface
uses
Classes, SysUtils, Math, types,
// LCL
LCLIntf, LCLType, LCLProc, Controls, Forms, GraphType, Graphics, Menus,
LCLIntf, LCLType, LCLProc, Controls, Forms, GraphType, Graphics, Menus, ComCtrls,
// IDEIntf
PropEditUtils, ComponentEditors, FormEditingIntf,
// IDE
@ -418,6 +418,7 @@ type
function IsSelected(APersistent: TPersistent): Boolean;
function IsOnlySelected(APersistent: TPersistent): Boolean;
function ParentLevel: integer;
function OkToCopy: boolean;
function OnlyNonVisualPersistentsSelected: boolean;
function OnlyVisualComponentsSelected: boolean;
function OnlyInvisiblePersistentsSelected: boolean;
@ -2899,6 +2900,18 @@ begin
end;
end;
function TControlSelection.OkToCopy: boolean;
// Prevent copying / cutting components that would lead to a crash or halt.
var
i: Integer;
begin
for i:=0 to FControls.Count-1 do
if (Items[i].Persistent is TCustomTabControl)
or (Items[i].Persistent is TCustomPage) then
Exit(False);
Result:=True;
end;
function TControlSelection.OnlyNonVisualPersistentsSelected: boolean;
var i: integer;
begin

View File

@ -1501,6 +1501,7 @@ function TDesigner.CanCopy: Boolean;
begin
Result := (ControlSelection.Count > 0) and
(ControlSelection.SelectionForm = Form) and
ControlSelection.OkToCopy and
not ControlSelection.OnlyInvisiblePersistentsSelected and
not ControlSelection.LookupRootSelected;
end;
@ -1509,6 +1510,7 @@ function TDesigner.CanPaste: Boolean;
begin
Result:= Assigned(Form) and
Assigned(FLookupRoot) and
ClipBoard.HasFormat(CF_Text) and
not (csDestroying in FLookupRoot.ComponentState);
end;