diff --git a/src/ce_interfaces.pas b/src/ce_interfaces.pas index bd09e91c..61a658ab 100644 --- a/src/ce_interfaces.pas +++ b/src/ce_interfaces.pas @@ -133,6 +133,11 @@ type (** * An implementer is informed about the current project(s). + * Usually observer should keep track of two ICECOmmonProject: + * - the free project: the project that's not in a group and that has to + * be freed manualy in order to be replaced. + * - the current project which can be either the free project or one of the + * project in the group *) ICEProjectObserver = interface(ISubjectType) ['ICEProjectObserver'] diff --git a/src/ce_lcldragdrop.pas b/src/ce_lcldragdrop.pas index 7a66a212..30e5a2ce 100644 --- a/src/ce_lcldragdrop.pas +++ b/src/ce_lcldragdrop.pas @@ -14,6 +14,7 @@ type TDDHandler = class(TObject, ICEProjectObserver) private fProj: ICECommonProject; + fFreeProj: ICECommonProject; procedure projNew(aProject: ICECommonProject); procedure projChanged(aProject: ICECommonProject); procedure projClosing(aProject: ICECommonProject); @@ -52,6 +53,8 @@ end; procedure TDDHandler.projNew(aProject: ICECommonProject); begin fProj := aProject; + if not fProj.inGroup then + fFreeProj := fProj; end; procedure TDDHandler.projChanged(aProject: ICECommonProject); @@ -60,13 +63,16 @@ end; procedure TDDHandler.projClosing(aProject: ICECommonProject); begin - if (fProj <> nil) and (fProj = aProject) then - fProj := nil; + fProj := nil; + if aProject = fFreeProj then + fFreeProj := nil; end; procedure TDDHandler.projFocused(aProject: ICECommonProject); begin fProj := aProject; + if not fProj.inGroup then + fFreeProj := fProj; end; procedure TDDHandler.projCompiling(aProject: ICECommonProject); @@ -128,24 +134,22 @@ begin if isValidNativeProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) then begin - if fProj.modified and not fProj.inGroup and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCENativeProject.create(nil); proj := true; end else if isValidDubProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) and not fFreeProj.inGroup then begin - if fProj.modified and not fProj.inGroup and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCEDubProject.create(nil); proj := true; diff --git a/src/ce_libmaneditor.pas b/src/ce_libmaneditor.pas index 9785eb98..f6eb0b66 100644 --- a/src/ce_libmaneditor.pas +++ b/src/ce_libmaneditor.pas @@ -59,6 +59,7 @@ type ); private fProj: ICECommonProject; + fFreeProj: ICECommonProject; procedure updateButtonsState; procedure projNew(aProject: ICECommonProject); procedure projChanged(aProject: ICECommonProject); @@ -121,6 +122,8 @@ end; procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject); begin fProj := aProject; + if not aProject.inGroup then + fFreeProj := aProject; end; procedure TCELibManEditorWidget.projChanged(aProject: ICECommonProject); @@ -134,15 +137,17 @@ end; procedure TCELibManEditorWidget.projClosing(aProject: ICECommonProject); begin - if fProj <> aProject then - exit; fProj := nil; + if aProject = fFreeProj then + fFreeProj := nil; updateButtonsState; end; procedure TCELibManEditorWidget.projFocused(aProject: ICECommonProject); begin fProj := aProject; + if not aProject.inGroup then + fFreeProj := aProject; updateButtonsState; end; @@ -511,24 +516,22 @@ begin // if isValidNativeProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) then begin - if fProj.modified and not fProj.inGroup and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCENativeProject.create(nil); fProj.loadFromFile(fname); end else if isValidDubProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) then begin - if fProj.modified and not fProj.inGroup and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCEDubProject.create(nil); fProj.loadFromFile(fname); diff --git a/src/ce_miniexplorer.pas b/src/ce_miniexplorer.pas index f5060972..1cb9ab12 100644 --- a/src/ce_miniexplorer.pas +++ b/src/ce_miniexplorer.pas @@ -85,6 +85,7 @@ type procedure TreeEnter(Sender: TObject); private fProj: ICECommonProject; + fFreeProj: ICECommonProject; fFavorites: TStringList; fLastFold: string; fLastListOrTree: TControl; @@ -307,6 +308,8 @@ end; procedure TCEMiniExplorerWidget.projNew(aProject: ICECommonProject); begin fProj := aProject; + if not aProject.inGroup then + fFreeProj := aProject; end; procedure TCEMiniExplorerWidget.projChanged(aProject: ICECommonProject); @@ -315,13 +318,16 @@ end; procedure TCEMiniExplorerWidget.projClosing(aProject: ICECommonProject); begin - if fProj = aProject then - fProj := nil; + fProj := nil; + if aProject = fFreeProj then + fFreeProj := nil; end; procedure TCEMiniExplorerWidget.projFocused(aProject: ICECommonProject); begin fProj := aProject; + if not aProject.inGroup then + fFreeProj := aProject; if visible and aProject.fileName.fileExists and fContextExpand then expandPath(aProject.fileName.extractFilePath); end; @@ -470,24 +476,22 @@ begin {$ENDIF} if isValidNativeProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) then begin - if not fProj.inGroup and fProj.modified and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCENativeProject.create(nil); proj := true; end else if isValidDubProject(fname) then begin - if assigned(fProj) then + if assigned(fFreeProj) then begin - if not fProj.inGroup and fProj.modified and - (dlgFileChangeClose(fProj.filename) = mrCancel) then - exit; - fProj.getProject.Free; + if fFreeProj.modified and (dlgFileChangeClose(fFreeProj.filename) = mrCancel) then + exit; + fFreeProj.getProject.Free; end; TCEDubProject.create(nil); proj := true;