mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 16:19:36 +02:00
Wrapped ComponentToString with a Try-Except so when you delete a control it doesn't crash.
Shane git-svn-id: trunk@377 -
This commit is contained in:
parent
07f6e25d94
commit
0b9d70ec39
@ -25,9 +25,12 @@ unit ControlSelection;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, LCLLinux, Controls, Forms, Graphics;
|
||||
Classes, LCLLinux, Controls, Forms, Graphics,SysUtils;
|
||||
|
||||
type
|
||||
|
||||
GenException = class(Exception);
|
||||
|
||||
TGrabberMoveEvent = procedure(Sender: TObject; dx, dy: Integer) of object;
|
||||
|
||||
TGrabIndex = 0..7;
|
||||
@ -223,7 +226,7 @@ implementation
|
||||
|
||||
|
||||
uses
|
||||
Sysutils, Math;
|
||||
Math;
|
||||
|
||||
const
|
||||
GRAB_CURSOR: array[TGrabIndex] of TCursor = (
|
||||
@ -436,11 +439,17 @@ end;
|
||||
|
||||
procedure TControlSelection.EndUpdate;
|
||||
begin
|
||||
if FUpdateLock<=0 then exit;
|
||||
dec(FUpdateLock);
|
||||
if FUpdateLock=0 then begin
|
||||
if FChangedDuringLock then DoChange;
|
||||
end;
|
||||
if FUpdateLock<=0 then exit;
|
||||
Writeln('1');
|
||||
dec(FUpdateLock);
|
||||
if FUpdateLock=0 then
|
||||
begin
|
||||
try
|
||||
if FChangedDuringLock then DoChange;
|
||||
except
|
||||
raise GenException.Create('Exception Occured');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TControlSelection.SetCustomForm;
|
||||
@ -525,12 +534,18 @@ end;
|
||||
|
||||
procedure TControlSelection.DoChange;
|
||||
begin
|
||||
try
|
||||
if (FUpdateLock>0) then
|
||||
FChangedDuringLock:=true
|
||||
else begin
|
||||
if Assigned(FOnChange) then FOnChange(Self);
|
||||
FChangedDuringLock:=true
|
||||
else
|
||||
begin
|
||||
if Assigned(fOnChange) then fOnChange(Self);
|
||||
FChangedDuringLock:=false;
|
||||
end;
|
||||
except
|
||||
Writeln('Exception in DoChange');
|
||||
//Crashes!!!! raise GenException.Create('Exception Occured');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TControlSelection.SetVisible(const Value: Boolean);
|
||||
|
@ -174,12 +174,9 @@ Begin
|
||||
Writeln('[TDesigner.RemoveControl] ',Control.Name,':',Control.ClassName);
|
||||
if Assigned(FOnRemoveComponent) then
|
||||
FOnRemoveComponent(Self,Control);
|
||||
Writeln('[TDesigner.RemoveControl] 1');
|
||||
FCustomForm.RemoveControl(TCOntrol(Control));
|
||||
//this send a message to notification and removes it from the controlselection
|
||||
Writeln('[TDesigner.RemoveControl] 2');
|
||||
FFormEditor.DeleteControl(Control);
|
||||
Writeln('[TDesigner.RemoveControl] end');
|
||||
end;
|
||||
|
||||
Procedure TDesigner.NudgeControl(DiffX, DiffY : Integer);
|
||||
@ -693,6 +690,7 @@ procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
||||
Begin
|
||||
if Operation = opInsert then
|
||||
begin
|
||||
Writeln('opInsert');
|
||||
end
|
||||
else
|
||||
if Operation = opRemove then
|
||||
|
@ -1502,23 +1502,37 @@ end;
|
||||
|
||||
function TObjectInspector.ComponentToString(c:TComponent):string;
|
||||
begin
|
||||
Try
|
||||
Result:=c.GetNamePath+': '+c.ClassName;
|
||||
except
|
||||
Result := '';
|
||||
Writeln('Exception: ObjectInspector ComponentToString');
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TObjectInspector.AddComponentToAvailComboBox(AComponent:TComponent);
|
||||
var Allowed:boolean;
|
||||
begin
|
||||
try
|
||||
Allowed:=true;
|
||||
if Assigned(FOnAddAvailableComponent) then
|
||||
FOnAddAvailableComponent(AComponent,Allowed);
|
||||
if Allowed then
|
||||
AvailCompsComboBox.Items.AddObject(
|
||||
ComponentToString(AComponent),AComponent);
|
||||
except
|
||||
Writeln('Exception: ObjectInspector AddComponentToAvailComboBox');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TObjectInspector.PropEditLookupRootChange;
|
||||
begin
|
||||
try
|
||||
FillComponentComboBox;
|
||||
except
|
||||
Writeln('Exception: ObjectInspector PropEditLookupRootCHange');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TObjectInspector.FillComponentComboBox;
|
||||
@ -1528,6 +1542,7 @@ var a:integer;
|
||||
begin
|
||||
//writeln('[TObjectInspector.FillComponentComboBox] A ',FUpdatingAvailComboBox
|
||||
//,' ',FPropertyEditorHook<>nil,' ',FPropertyEditorHook.LookupRoot<>nil);
|
||||
try
|
||||
if FUpdatingAvailComboBox then exit;
|
||||
FUpdatingAvailComboBox:=true;
|
||||
AvailCompsComboBox.Items.BeginUpdate;
|
||||
@ -1551,6 +1566,9 @@ begin
|
||||
AvailCompsComboBox.Text:='';
|
||||
end else
|
||||
AvailCompsComboBox.ItemIndex:=a;
|
||||
except
|
||||
Writeln('Exception: ObjectInspector FillComponentComboBox');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TObjectInspector.SetSelections(
|
||||
|
@ -2865,10 +2865,14 @@ end;
|
||||
|
||||
procedure TPropertyEditorHook.SetLookupRoot(AComponent:TComponent);
|
||||
begin
|
||||
try
|
||||
if FLookupRoot=AComponent then exit;
|
||||
FLookupRoot:=AComponent;
|
||||
if Assigned(FOnChangeLookupRoot) then
|
||||
FOnChangeLookupRoot();
|
||||
except
|
||||
Writeln('Exception in PropEdits.pp SetLookupRoot');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -523,16 +523,24 @@ end;
|
||||
procedure TCustomFormEditor.SetSelectedComponents(
|
||||
TheSelectedComponents : TComponentSelectionList);
|
||||
begin
|
||||
if FSelectedComponents.Count>0 then begin
|
||||
if FSelectedComponents[0].Owner<>nil then begin
|
||||
Obj_Inspector.PropertyEditorHook.LookupRoot:=
|
||||
FSelectedComponents[0].Owner;
|
||||
end else begin
|
||||
try
|
||||
if FSelectedComponents.Count>0 then
|
||||
begin
|
||||
if FSelectedComponents[0].Owner<>nil then
|
||||
begin
|
||||
Obj_Inspector.PropertyEditorHook.LookupRoot:= FSelectedComponents[0].Owner;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Obj_Inspector.PropertyEditorHook.LookupRoot:=FSelectedComponents[0];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
FSelectedComponents.Assign(TheSelectedComponents);
|
||||
Obj_Inspector.Selections := FSelectedComponents;
|
||||
except
|
||||
Writeln('Exception in CustomFormEditor SetSelectedComponents');
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
Function TCustomFormEditor.AddSelected(Value : TComponent) : Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user