From: <dav...@us...> - 2009-08-19 20:25:22
|
Revision: 852 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=852&view=rev Author: davidvtaylor Date: 2009-08-19 20:25:12 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Fix for update problem with the attribute view feature on Model Explorer - Added checks for null Subject to avoid AV when switching projects - Reworked and simplified attribute view refresh logic - Remove ExplictXXX properties for forms for older Delphi versions Modified Paths: -------------- trunk/Source/Design/InstantAttributeEditor.pas trunk/Source/Design/InstantAttributeView.pas trunk/Source/Design/InstantClassEditor.dfm trunk/Source/Design/InstantModelExplorer.dfm trunk/Source/Design/InstantModelExplorer.pas Modified: trunk/Source/Design/InstantAttributeEditor.pas =================================================================== --- trunk/Source/Design/InstantAttributeEditor.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantAttributeEditor.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -263,8 +263,11 @@ begin inherited; - LoadOptions; - LoadMethods; + if (assigned(Subject)) then + begin + LoadOptions; + LoadMethods; + end; end; procedure TInstantAttributeEditorForm.LoadEnums(TypeInfo: PTypeInfo; Modified: trunk/Source/Design/InstantAttributeView.pas =================================================================== --- trunk/Source/Design/InstantAttributeView.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantAttributeView.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -447,12 +447,14 @@ procedure TInstantAttributeViewFrame.PopulateInheritedAttributes; begin - LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); + if (assigned(Subject)) then + LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); end; procedure TInstantAttributeViewFrame.PopulateIntroducedAttributes; begin - LoadAttributeView(IntroducedAttributesView, Subject, False); + if (assigned(Subject)) then + LoadAttributeView(IntroducedAttributesView, Subject, False); end; procedure TInstantAttributeViewFrame.RestoreLayout; Modified: trunk/Source/Design/InstantClassEditor.dfm =================================================================== --- trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 20:25:12 UTC (rev 852) @@ -6,15 +6,11 @@ ClientWidth = 400 OldCreateOrder = True OnCreate = FormCreate - ExplicitWidth = 408 - ExplicitHeight = 399 PixelsPerInch = 96 TextHeight = 13 inherited EditPanel: TPanel Width = 400 Height = 334 - ExplicitWidth = 400 - ExplicitHeight = 334 object PageControl: TPageControl Left = 4 Top = 4 @@ -131,21 +127,16 @@ Height = 290 Align = alClient TabOrder = 0 - ExplicitHeight = 290 inherited AttributesSplitter: TSplitter Top = 186 - ExplicitTop = 186 end inherited InheritedAttributesPanel: TPanel Top = 190 - ExplicitTop = 190 end inherited IntroducedAttributesPanel: TPanel Height = 186 - ExplicitHeight = 186 inherited IntroducedAttributesView: TListView Height = 170 - ExplicitHeight = 170 end end end @@ -155,16 +146,11 @@ inherited BottomPanel: TPanel Top = 334 Width = 400 - ExplicitTop = 334 - ExplicitWidth = 400 inherited ButtonPanel: TPanel Left = 240 - ExplicitLeft = 240 inherited OkButton: TButton Left = 1 Top = 6 - ExplicitLeft = 1 - ExplicitTop = 6 end end end Modified: trunk/Source/Design/InstantModelExplorer.dfm =================================================================== --- trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 20:25:12 UTC (rev 852) @@ -127,44 +127,30 @@ Height = 218 Align = alClient TabOrder = 1 - ExplicitTop = 25 - ExplicitWidth = 410 - ExplicitHeight = 218 inherited AttributesSplitter: TSplitter Top = 114 Width = 410 - ExplicitTop = 114 - ExplicitWidth = 410 end inherited InheritedAttributesPanel: TPanel Top = 118 Width = 410 - ExplicitTop = 118 - ExplicitWidth = 410 inherited InheritedAttributesLabel: TLabel Width = 410 - ExplicitWidth = 410 end inherited InheritedAttributesView: TListView Width = 410 Font.Pitch = fpVariable - ExplicitWidth = 410 end end inherited IntroducedAttributesPanel: TPanel Width = 410 Height = 114 - ExplicitWidth = 410 - ExplicitHeight = 114 inherited IntroducedAttributesLabel: TLabel Width = 410 - ExplicitWidth = 410 end inherited IntroducedAttributesView: TListView Width = 410 Height = 98 - ExplicitWidth = 410 - ExplicitHeight = 98 end end inherited Actions: TActionList Modified: trunk/Source/Design/InstantModelExplorer.pas =================================================================== --- trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -168,7 +168,6 @@ FOnApplyClass: TInstantCodeClassApplyEvent; FOnGotoSource: TInstantGotoSourceEvent; FOnLoadModel: TInstantCodeModelEvent; - FViewUpdateDisableCount: Integer; function GetFocusedClass: TInstantCodeClass; function GetSelectedNode: TTreeNode; procedure SetError(E: Exception); @@ -185,14 +184,12 @@ function ClassFromNode(Node: TTreeNode): TInstantCodeClass; procedure DoApplyClass(AClass: TInstantCodeClass; ChangeInfo: TInstantCodeClassChangeInfo); - procedure DisableViewUpdate; - procedure EnableViewUpdate; - function ViewUpdateEnabled: boolean; function EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; procedure GotoNodeSource(Node: TTreeNode); procedure GotoSource(const FileName: string; Pos: TInstantCodePos); procedure LoadModel; procedure UpdateActions; override; + procedure RefreshAttributeView; property SelectedNode: TTreeNode read GetSelectedNode; public constructor Create(AOwner: TComponent); override; @@ -397,22 +394,6 @@ FOnApplyClass(Self, AClass, ChangeInfo); end; -procedure TInstantModelExplorerForm.DisableViewUpdate; - begin - inc(FViewUpdateDisableCount); - end; - -procedure TInstantModelExplorerForm.EnableViewUpdate; - begin - if (FViewUpdateDisableCount > 0) then - dec(FViewUpdateDisableCount); - end; - -function TInstantModelExplorerForm.ViewUpdateEnabled: boolean; - begin - Result := (FViewUpdateDisableCount = 0); - end; - function TInstantModelExplorerForm.EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; const @@ -640,8 +621,7 @@ Node: TTreeNode); begin FSelectedNode := nil; - if (ViewUpdateEnabled) then - ViewClassAttributes(FocusedClass); + RefreshAttributeView; end; procedure TInstantModelExplorerForm.ModelViewGetImageIndex(Sender: TObject; @@ -738,6 +718,7 @@ AttributePanel.Visible := Visible; AttributeSplitter.Visible := Visible; ViewAttributeButton.Down := Visible; + RefreshAttributeView; end; procedure TInstantModelExplorerForm.SetError(E: Exception); @@ -791,6 +772,12 @@ CollapseAllAction.Enabled := AtClass; end; +procedure TInstantModelExplorerForm.RefreshAttributeView; + begin + if (AttributePanel.Visible) then + ViewClassAttributes(FocusedClass); + end; + procedure TInstantModelExplorerForm.UpdateModel; function FindClassNode(Parent: TTreeNode; @@ -901,49 +888,44 @@ //FAttributeFrame.Clear; InstantAttributeViewFrame.Clear; - DisableViewUpdate; - + Level := 0; + FSelectedNode := nil; + ModelView.Items.BeginUpdate; try - Level := 0; - FSelectedNode := nil; - ModelView.Items.BeginUpdate; - try - if Assigned(FError) then - begin - ModelView.Items.Clear; - {$IFDEF MSWINDOWS} - ModelView.ShowRoot := False; - {$ENDIF} - ModelView.Items.AddObject(nil, FError.Text, FError) - end else - begin - Nodes := TList.Create; - try - {$IFDEF MSWINDOWS} - ModelView.ShowRoot := True; - {$ENDIF} - for I := 0 to Pred(Model.ClassCount) do - begin - AClass := Model.Classes[I]; - if (Style = msRelations) or not Assigned(AClass.BaseClass) then - Nodes.Add(AddClass(nil, AClass, '', Level)); - end; - ModelView.AlphaSort; - RemoveInvalidNodes(nil, Nodes); - FirstNode := ModelView.Items.GetFirstNode; - if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then - FirstNode.Expand(False); - finally - Nodes.Free; + if Assigned(FError) then + begin + ModelView.Items.Clear; +{$IFDEF MSWINDOWS} + ModelView.ShowRoot := False; +{$ENDIF} + ModelView.Items.AddObject(nil, FError.Text, FError) + end else + begin + Nodes := TList.Create; + try +{$IFDEF MSWINDOWS} + ModelView.ShowRoot := True; +{$ENDIF} + for I := 0 to Pred(Model.ClassCount) do + begin + AClass := Model.Classes[I]; + if (Style = msRelations) or not Assigned(AClass.BaseClass) then + Nodes.Add(AddClass(nil, AClass, '', Level)); end; + ModelView.AlphaSort; + RemoveInvalidNodes(nil, Nodes); + FirstNode := ModelView.Items.GetFirstNode; + if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then + FirstNode.Expand(False); + finally + Nodes.Free; end; - finally; - ModelView.Items.EndUpdate; - ModelView.Repaint; end; - finally - EnableViewUpdate; + finally; + ModelView.Items.EndUpdate; + ModelView.Repaint; end; + RefreshAttributeView; end; procedure TInstantModelExplorerForm.ViewInheritanceActionExecute( |