IDEIntf: object inspector: fixed setting propertyeditorhook

git-svn-id: trunk@37913 -
This commit is contained in:
mattias 2012-07-12 10:05:10 +00:00
parent 9f8e1443ff
commit 4fb746ee2c
2 changed files with 25 additions and 19 deletions

View File

@ -1648,10 +1648,10 @@ begin
for a:=0 to FRows.Count-1 do Rows[a].Free; for a:=0 to FRows.Count-1 do Rows[a].Free;
FRows.Clear; FRows.Clear;
// get properties // get properties
if FPropertyEditorHook=Nil then if FSelection.Count>0 then begin
debugln('TOICustomPropertyGrid.BuildPropertyList: FPropertyEditorHook=Nil'); GetPersistentProperties(FSelection, FFilter + [tkClass], FPropertyEditorHook,
GetPersistentProperties(FSelection, FFilter + [tkClass], FPropertyEditorHook, @AddPropertyEditor, @EditorFilter);
@AddPropertyEditor, @EditorFilter); end;
// sort // sort
FRows.Sort(@SortGridRows); FRows.Sort(@SortGridRows);
for a:=0 to FRows.Count-1 do begin for a:=0 to FRows.Count-1 do begin
@ -4066,7 +4066,12 @@ begin
FPropertyEditorHook.AddHandlerRefreshPropertyValues( FPropertyEditorHook.AddHandlerRefreshPropertyValues(
@HookRefreshPropertyValues); @HookRefreshPropertyValues);
FPropertyEditorHook.AddHandlerSetSelection(@HookSetSelection); FPropertyEditorHook.AddHandlerSetSelection(@HookSetSelection);
Selection := nil;
for Page:=Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page]<>nil then
GridControl[Page].PropertyEditorHook:=FPropertyEditorHook;
if EnableHookGetSelection then begin if EnableHookGetSelection then begin
// the propertyeditorhook gets the selection from the OI
FPropertyEditorHook.AddHandlerGetSelection(@HookGetSelection); FPropertyEditorHook.AddHandlerGetSelection(@HookGetSelection);
// select root component // select root component
FSelection.Clear; FSelection.Clear;
@ -4074,6 +4079,7 @@ begin
and (FPropertyEditorHook.LookupRoot is TComponent) then and (FPropertyEditorHook.LookupRoot is TComponent) then
FSelection.Add(TComponent(FPropertyEditorHook.LookupRoot)); FSelection.Add(TComponent(FPropertyEditorHook.LookupRoot));
end else begin end else begin
// the OI gets the selection from the propertyeditorhook
ASelection:=TPersistentSelectionList.Create; ASelection:=TPersistentSelectionList.Create;
try try
FPropertyEditorHook.GetSelection(ASelection); FPropertyEditorHook.GetSelection(ASelection);
@ -4083,9 +4089,6 @@ begin
end; end;
end; end;
FillPersistentComboBox; FillPersistentComboBox;
for Page:=Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page]<>nil then
GridControl[Page].PropertyEditorHook:=FPropertyEditorHook;
ComponentTree.PropertyEditorHook:=FPropertyEditorHook; ComponentTree.PropertyEditorHook:=FPropertyEditorHook;
RefreshSelection; RefreshSelection;
end; end;
@ -4284,21 +4287,26 @@ end;
procedure TObjectInspectorDlg.SetSelection(const ASelection: TPersistentSelectionList); procedure TObjectInspectorDlg.SetSelection(const ASelection: TPersistentSelectionList);
begin begin
if (not Assigned(ASelection)) then if ASelection<>nil then begin
exit; if FSelection.IsEqual(ASelection) then
if FSelection.IsEqual(ASelection) then begin
begin if FInSelection then
if FInSelection then exit; // prevent endless loops
exit; // prevent endless loops if (not ASelection.ForceUpdate) then
if (not ASelection.ForceUpdate) then exit; // nothing changed
exit; // nothing changed ASelection.ForceUpdate:=false;
ASelection.ForceUpdate:=false; end;
end else begin
if FSelection.Count=0 then exit;
end; end;
FInSelection := True; FInSelection := True;
try try
// ToDo: Clear filter only if a selected node is hidden (Visible=False) // ToDo: Clear filter only if a selected node is hidden (Visible=False)
CompFilterEdit.Filter:=''; CompFilterEdit.Filter:='';
FSelection.Assign(ASelection); if ASelection<>nil then
FSelection.Assign(ASelection)
else
FSelection.Clear;
SetAvailComboBoxText; SetAvailComboBoxText;
RefreshSelection; RefreshSelection;
if Assigned(FOnSelectPersistentsInOI) then if Assigned(FOnSelectPersistentsInOI) then

View File

@ -2213,8 +2213,6 @@ var
PropListSize: Integer; PropListSize: Integer;
begin begin
FPropertyHook:=Hook; FPropertyHook:=Hook;
if not Assigned(FPropertyHook) then
debugln('TPropertyEditor.Create : Hook=Nil <- Wrong!');
PropListSize:=APropCount * SizeOf(TInstProp); PropListSize:=APropCount * SizeOf(TInstProp);
GetMem(FPropList,PropListSize); GetMem(FPropList,PropListSize);
FillChar(FPropList^,PropListSize,0); FillChar(FPropList^,PropListSize,0);