diff --git a/ide/lazbuild.lpr b/ide/lazbuild.lpr index 19b1273dac..b77700c2e9 100644 --- a/ide/lazbuild.lpr +++ b/ide/lazbuild.lpr @@ -517,7 +517,7 @@ begin // check if package is already loaded Result:=PackageGraph.FindPackageWithFilename(AFilename); if (Result<>nil) then exit; - if not FileExistsUTF8(AFilename) then + if not FileExists(AFilename) then PrintErrorAndHalt(ErrorLoadPackageFailed, 'Package file not found: "' + AFilename + '"'); Result:=TLazPackage.Create; @@ -533,8 +533,13 @@ begin if not IsValidPkgName(Result.Name) then PrintErrorAndHalt(ErrorPackageNameInvalid, Format(lisPkgMangThePackageNameOfTheFileIsInvalid, [Result.Name, LineEnding, Result.Filename])); + // check if Package with same name is already loaded ConflictPkg:=PackageGraph.FindPackageWithName(Result.Name,nil); + if not PackageGraph.PackageCanBeReplaced(ConflictPkg,Result) then + PrintErrorAndHalt(ErrorLoadPackageFailed, + 'Cannot replace loaded package '+ConflictPkg.IDAsString+' with '+Result.IDAsString+' from "'+Result.Filename+'"'); + if ConflictPkg<>nil then begin // replace package PackageGraph.ReplacePackage(ConflictPkg,Result); diff --git a/ide/packages/idepackager/packagedefs.pas b/ide/packages/idepackager/packagedefs.pas index 588d01a557..f50071539a 100644 --- a/ide/packages/idepackager/packagedefs.pas +++ b/ide/packages/idepackager/packagedefs.pas @@ -546,7 +546,7 @@ type FStorePathDelim: TPathDelimSwitch; FTopologicalLevel: integer; FTranslated: string; - FUpdateLock: integer; + FUpdateLocks: TStringArray; FUsageOptions: TPkgAdditionalCompilerOptions; FUserIgnoreChangeStamp: integer; FUserReadOnly: boolean; @@ -613,8 +613,10 @@ type procedure BackupOptions; procedure RestoreOptions; // modified - procedure BeginUpdate; - procedure EndUpdate; + procedure BeginUpdate(const Reference: string); + procedure EndUpdate(const Reference: string); + function IsUpdateLocked: boolean; + procedure WriteUpdateLocks(const Prefix: string); procedure LockModified; procedure UnlockModified; function ReadOnly: boolean; override; @@ -2676,6 +2678,11 @@ destructor TLazPackage.Destroy; var pod: TPkgOutputDir; begin + if IsUpdateLocked then + begin + WriteUpdateLocks('TLazPackage.Destroy'); + raise Exception.Create('TLazPackage.Destroy 20240913140628'); + end; Include(FFlags,lpfDestroying); Clear; for pod in TPkgOutputDir do @@ -2712,21 +2719,50 @@ begin CompilerOptions.Modified:=FOptionsBackup.CompilerOptions.Modified; end; -procedure TLazPackage.BeginUpdate; +procedure TLazPackage.BeginUpdate(const Reference: string); begin - inc(FUpdateLock); + Insert(Reference,FUpdateLocks,length(FUpdateLocks)); FDefineTemplates.BeginUpdate; FSourceDirectories.BeginUpdate; end; -procedure TLazPackage.EndUpdate; +procedure TLazPackage.EndUpdate(const Reference: string); +var + l: SizeInt; begin - if FUpdateLock=0 then RaiseGDBException('TLazPackage.EndUpdate'); - dec(FUpdateLock); + l:=length(FUpdateLocks); + if l=0 then + raise Exception.Create('Error: (lazarus) TLazPackage.EndUpdate 20240913135959'); + dec(l); + if FUpdateLocks[l]<>Reference then + begin + WriteUpdateLocks('TLazPackage.EndUpdate'); + debugln(['Error: (lazarus) TLazPackage.EndUpdate cannot remove reference "'+Reference+'"']); + raise Exception.Create('TLazPackage.EndUpdate 20240913140039 cannot remove reference "'+Reference+'"'); + end; + + SetLength(FUpdateLocks,l); FDefineTemplates.EndUpdate; FSourceDirectories.EndUpdate; end; +function TLazPackage.IsUpdateLocked: boolean; +begin + Result:=length(FUpdateLocks)>0; +end; + +procedure TLazPackage.WriteUpdateLocks(const Prefix: string); +var + l, i: Integer; +begin + l:=length(FUpdateLocks); + if l=0 then + debugln(['TLazPackage.WriteUpdateLocks ',Prefix,' ',IDAsString,' not locked']) + else + for i:=0 to l-1 do + debugln(['Info: (lazarus) ',Prefix,' '+IDAsString+' UpdateLocks[',i,']="',FUpdateLocks[i],'"']); +end; + procedure TLazPackage.Clear; var i: Integer; @@ -2903,66 +2939,69 @@ begin Flags:=Flags+[lpfLoading]; FileVersion:=XMLConfig.GetValue(Path+'Version',0); OldFilename:=Filename; - BeginUpdate; - Clear; - Filename:=OldFilename; - LockModified; - LoadFlags(Path); - StorePathDelim:=CheckPathDelim(XMLConfig.GetValue(Path+'PathDelim/Value','/'),PathDelimChanged); - Name:=XMLConfig.GetValue(Path+'Name/Value',''); - FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value', - LazPackageTypeIdents[lptRunTime])); - FBuildMethod:=StringToBuildMethod(XMLConfig.GetValue(Path+'BuildMethod/Value', - SBuildMethod[bmLazarus])); - FAddToProjectUsesSection:=XMLConfig.GetValue(Path+'AddToProjectUsesSection/Value', - FileVersion<4); // since version 4 the default is false - FAuthor:=XMLConfig.GetValue(Path+'Author/Value',''); - FAutoUpdate:=NameToAutoUpdatePolicy( - XMLConfig.GetValue(Path+'AutoUpdate/Value','')); - if FileVersion<2 then - CompilerOptions.LoadFromXMLConfig(XMLConfig,'CompilerOptions/') - else - CompilerOptions.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/'); - FDescription:=XMLConfig.GetValue(Path+'Description/Value',''); - FLicense:=XMLConfig.GetValue(Path+'License/Value',''); - PkgVersionLoadFromXMLConfig(FVersion,XMLConfig,Path+'Version/',FileVersion); - FIconFile:=SwitchPathDelims(XMLConfig.GetValue(Path+'IconFile/Value',''), - PathDelimChanged); - OutputStateFile:=SwitchPathDelims( - XMLConfig.GetValue(Path+'OutputStateFile/Value',''), - PathDelimChanged); - FFPDocPaths:=SwitchPathDelims(XMLConfig.GetValue(Path+'LazDoc/Paths',''), - PathDelimChanged); - FFPDocPackageName:=XMLConfig.GetValue(Path+'LazDoc/PackageName',''); - // i18n - if FileVersion<3 then begin - FPOOutputDirectory := SwitchPathDelims( - xmlconfig.GetValue(Path+'RST/OutDir', ''),PathDelimChanged); - EnableI18N := FPOOutputDirectory <> ''; - end else begin - EnableI18N := xmlconfig.GetValue(Path+'i18n/EnableI18N/Value', False); - FPOOutputDirectory := SwitchPathDelims( - xmlconfig.GetValue(Path+'i18n/OutDir/Value', ''),PathDelimChanged); - end; - EnableI18NForLFM:=xmlconfig.GetValue(Path+'i18n/EnableI18NForLFM/Value', false); - - LoadFiles(Path+'Files/',FFiles); - UpdateSourceDirectories; - LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/', - FFirstRequiredDependency,pddRequires,Self,false,false); - FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/', - PathDelimChanged); - fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/', - PathDelimChanged); - LoadStringList(XMLConfig,FProvides,Path+'Provides/'); - Config:=TXMLOptionsStorage.Create(XMLConfig); + BeginUpdate('TLazPackage.LoadFromXMLConfig'); try - TConfigMemStorage(CustomOptions).LoadFromConfig(Config,Path+'CustomOptions/'); + Clear; + Filename:=OldFilename; + LockModified; + LoadFlags(Path); + StorePathDelim:=CheckPathDelim(XMLConfig.GetValue(Path+'PathDelim/Value','/'),PathDelimChanged); + Name:=XMLConfig.GetValue(Path+'Name/Value',''); + FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value', + LazPackageTypeIdents[lptRunTime])); + FBuildMethod:=StringToBuildMethod(XMLConfig.GetValue(Path+'BuildMethod/Value', + SBuildMethod[bmLazarus])); + FAddToProjectUsesSection:=XMLConfig.GetValue(Path+'AddToProjectUsesSection/Value', + FileVersion<4); // since version 4 the default is false + FAuthor:=XMLConfig.GetValue(Path+'Author/Value',''); + FAutoUpdate:=NameToAutoUpdatePolicy( + XMLConfig.GetValue(Path+'AutoUpdate/Value','')); + if FileVersion<2 then + CompilerOptions.LoadFromXMLConfig(XMLConfig,'CompilerOptions/') + else + CompilerOptions.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/'); + FDescription:=XMLConfig.GetValue(Path+'Description/Value',''); + FLicense:=XMLConfig.GetValue(Path+'License/Value',''); + PkgVersionLoadFromXMLConfig(FVersion,XMLConfig,Path+'Version/',FileVersion); + FIconFile:=SwitchPathDelims(XMLConfig.GetValue(Path+'IconFile/Value',''), + PathDelimChanged); + OutputStateFile:=SwitchPathDelims( + XMLConfig.GetValue(Path+'OutputStateFile/Value',''), + PathDelimChanged); + FFPDocPaths:=SwitchPathDelims(XMLConfig.GetValue(Path+'LazDoc/Paths',''), + PathDelimChanged); + FFPDocPackageName:=XMLConfig.GetValue(Path+'LazDoc/PackageName',''); + // i18n + if FileVersion<3 then begin + FPOOutputDirectory := SwitchPathDelims( + xmlconfig.GetValue(Path+'RST/OutDir', ''),PathDelimChanged); + EnableI18N := FPOOutputDirectory <> ''; + end else begin + EnableI18N := xmlconfig.GetValue(Path+'i18n/EnableI18N/Value', False); + FPOOutputDirectory := SwitchPathDelims( + xmlconfig.GetValue(Path+'i18n/OutDir/Value', ''),PathDelimChanged); + end; + EnableI18NForLFM:=xmlconfig.GetValue(Path+'i18n/EnableI18NForLFM/Value', false); + + LoadFiles(Path+'Files/',FFiles); + UpdateSourceDirectories; + LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/', + FFirstRequiredDependency,pddRequires,Self,false,false); + FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/', + PathDelimChanged); + fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/', + PathDelimChanged); + LoadStringList(XMLConfig,FProvides,Path+'Provides/'); + Config:=TXMLOptionsStorage.Create(XMLConfig); + try + TConfigMemStorage(CustomOptions).LoadFromConfig(Config,Path+'CustomOptions/'); + finally + Config.Free; + end; finally - Config.Free; + EndUpdate('TLazPackage.LoadFromXMLConfig'); end; - EndUpdate; Modified:=false; UnlockModified; Flags:=Flags-[lpfLoading]; diff --git a/ide/packages/idepackager/packagesystem.pas b/ide/packages/idepackager/packagesystem.pas index d59f8f6b64..bec228d38b 100644 --- a/ide/packages/idepackager/packagesystem.pas +++ b/ide/packages/idepackager/packagesystem.pas @@ -1047,7 +1047,7 @@ begin PkgLink.LPKFileDateValid:=true; XMLConfig:=TXMLConfig.Create(nil); NewPackage:=TLazPackage.Create; - NewPackage.BeginUpdate; + NewPackage.BeginUpdate('TLazPackageGraph.OpenDependencyWithPackageLink'); NewPackage.Filename:=AFilename; NewPackage.OnModifySilently := @PkgModify; Result:=LoadXMLConfigFromCodeBuffer(AFilename,XMLConfig, @@ -1069,20 +1069,27 @@ begin DebugLn('Error: (lazarus) package file "'+AFilename+'" and name "'+NewPackage.Name+'" mismatch.'); exit(mrCancel); end; + OldPackage:=FindPackageWithName(NewPackage.Name,NewPackage); + if (OldPackage<>nil) and not PackageCanBeReplaced(OldPackage,NewPackage) then + begin + debugln('Error: (lazarus) Open dependency ['+Dependency.PackageName+']: Failed to replace "'+OldPackage.Filename+'" with "'+NewPackage.Filename+'"'); + CTDumpStack; + exit(mrCancel); + end; + // ok if pvPkgSearch in Verbosity then - debugln('Info: (lazarus) Open dependency ['+Dependency.PackageName+']: Success: "'+NewPackage.Filename+'"'); + debugln('Info: (lazarus) Open dependency ['+Dependency.PackageName+']: Successfully loaded "'+NewPackage.Filename+'"'); Result:=mrOk; Dependency.RequiredPackage:=NewPackage; Dependency.LoadPackageResult:=lprSuccess; - OldPackage:=FindPackageWithName(NewPackage.Name,NewPackage); if OldPackage=nil then AddPackage(NewPackage) else ReplacePackage(OldPackage,NewPackage); finally if Assigned(NewPackage) then - NewPackage.EndUpdate; + NewPackage.EndUpdate('TLazPackageGraph.OpenDependencyWithPackageLink'); if Result<>mrOk then NewPackage.Free; EndUpdate; @@ -2200,75 +2207,77 @@ begin FTree.Add(APackage); FItems.Add(APackage); - if IsCompiledInBasePackage(APackage.Name) then begin - APackage.Installed:=pitStatic; - APackage.AutoInstall:=pitStatic; - if SysUtils.CompareText(APackage.Name,'FCL')=0 then begin - SetBasePackage(FFCLPackage); - APackage.SetAllComponentPriorities(FCLCompPriority); - end - else if SysUtils.CompareText(APackage.Name,'LazUtils')=0 then - SetBasePackage(FLazUtilsPackage) - else if SysUtils.CompareText(APackage.Name,'BuildIntf')=0 then begin - SetBasePackage(FBuildIntfPackage); - APackage.SetAllComponentPriorities(IDEIntfCompPriority); - end - else if SysUtils.CompareText(APackage.Name,'LCLBase')=0 then begin - SetBasePackage(FLCLBasePackage); - APackage.SetAllComponentPriorities(LCLCompPriority); - end - else if SysUtils.CompareText(APackage.Name,'LCL')=0 then begin - SetBasePackage(FLCLPackage); - APackage.SetAllComponentPriorities(LCLCompPriority); - end - else if SysUtils.CompareText(APackage.Name,'IDEIntf')=0 then begin - SetBasePackage(FIDEIntfPackage); - APackage.SetAllComponentPriorities(IDEIntfCompPriority); - end - else if SysUtils.CompareText(APackage.Name,'LazDebuggerIntf')=0 then - SetBasePackage(FLazDebuggerIntfPackage) - else if SysUtils.CompareText(APackage.Name,'DebuggerIntf')=0 then - SetBasePackage(FDebuggerIntfPackage) - else if SysUtils.CompareText(APackage.Name,'LazDebuggerGdbmi')=0 then - SetBasePackage(FLazDebuggerGdbmiPackage) - else if SysUtils.CompareText(APackage.Name,'IdeDebugger')=0 then - SetBasePackage(FIdeDebuggerPackage) - else if SysUtils.CompareText(APackage.Name,'IdeUtilsPkg')=0 then - SetBasePackage(FIdeUtilsPkgPackage) - else if SysUtils.CompareText(APackage.Name,'IdeConfig')=0 then - SetBasePackage(FIdeConfigPackage) - else if SysUtils.CompareText(APackage.Name,'IdePackagerConfig')=0 then - SetBasePackage(FIdePackagerPackage) - else if SysUtils.CompareText(APackage.Name,'IdeProject')=0 then - SetBasePackage(FIdeProjectPackage) - else if SysUtils.CompareText(APackage.Name,'SynEdit')=0 then - SetBasePackage(FSynEditPackage) - else if SysUtils.CompareText(APackage.Name,'LazControls')=0 then - SetBasePackage(FLazControlsPackage) - else if SysUtils.CompareText(APackage.Name,'CodeTools')=0 then - SetBasePackage(FCodeToolsPackage); - if FLazarusBasePackages.IndexOf(APackage)<0 then - FLazarusBasePackages.Add(APackage); - end; + APackage.BeginUpdate('TLazPackageGraph.AddPackage'); + try + if IsCompiledInBasePackage(APackage.Name) then begin + APackage.Installed:=pitStatic; + APackage.AutoInstall:=pitStatic; + if SysUtils.CompareText(APackage.Name,'FCL')=0 then begin + SetBasePackage(FFCLPackage); + APackage.SetAllComponentPriorities(FCLCompPriority); + end + else if SysUtils.CompareText(APackage.Name,'LazUtils')=0 then + SetBasePackage(FLazUtilsPackage) + else if SysUtils.CompareText(APackage.Name,'BuildIntf')=0 then begin + SetBasePackage(FBuildIntfPackage); + APackage.SetAllComponentPriorities(IDEIntfCompPriority); + end + else if SysUtils.CompareText(APackage.Name,'LCLBase')=0 then begin + SetBasePackage(FLCLBasePackage); + APackage.SetAllComponentPriorities(LCLCompPriority); + end + else if SysUtils.CompareText(APackage.Name,'LCL')=0 then begin + SetBasePackage(FLCLPackage); + APackage.SetAllComponentPriorities(LCLCompPriority); + end + else if SysUtils.CompareText(APackage.Name,'IDEIntf')=0 then begin + SetBasePackage(FIDEIntfPackage); + APackage.SetAllComponentPriorities(IDEIntfCompPriority); + end + else if SysUtils.CompareText(APackage.Name,'LazDebuggerIntf')=0 then + SetBasePackage(FLazDebuggerIntfPackage) + else if SysUtils.CompareText(APackage.Name,'DebuggerIntf')=0 then + SetBasePackage(FDebuggerIntfPackage) + else if SysUtils.CompareText(APackage.Name,'LazDebuggerGdbmi')=0 then + SetBasePackage(FLazDebuggerGdbmiPackage) + else if SysUtils.CompareText(APackage.Name,'IdeDebugger')=0 then + SetBasePackage(FIdeDebuggerPackage) + else if SysUtils.CompareText(APackage.Name,'IdeUtilsPkg')=0 then + SetBasePackage(FIdeUtilsPkgPackage) + else if SysUtils.CompareText(APackage.Name,'IdeConfig')=0 then + SetBasePackage(FIdeConfigPackage) + else if SysUtils.CompareText(APackage.Name,'IdePackagerConfig')=0 then + SetBasePackage(FIdePackagerPackage) + else if SysUtils.CompareText(APackage.Name,'IdeProject')=0 then + SetBasePackage(FIdeProjectPackage) + else if SysUtils.CompareText(APackage.Name,'SynEdit')=0 then + SetBasePackage(FSynEditPackage) + else if SysUtils.CompareText(APackage.Name,'LazControls')=0 then + SetBasePackage(FLazControlsPackage) + else if SysUtils.CompareText(APackage.Name,'CodeTools')=0 then + SetBasePackage(FCodeToolsPackage); + if FLazarusBasePackages.IndexOf(APackage)<0 then + FLazarusBasePackages.Add(APackage); + end; - // open all required dependencies - Dependency:=APackage.FirstRequiredDependency; - while Dependency<>nil do begin - OpenDependency(Dependency,false); - Dependency:=Dependency.NextRequiresDependency; + // open all required dependencies + Dependency:=APackage.FirstRequiredDependency; + while Dependency<>nil do begin + if OpenDependency(Dependency,false)<>lprSuccess then + debugln(['Warning: (lazarus) TLazPackageGraph.AddPackage failed to open: ',Dependency.AsString(true,false)]); + Dependency:=Dependency.NextRequiresDependency; + end; + + // update all missing dependencies + UpdateBrokenDependenciesToPackage(APackage); + + // activate define templates + APackage.DefineTemplates.Active:=true; + if Assigned(OnAddPackage) then + OnAddPackage(APackage); + finally + APackage.EndUpdate('TLazPackageGraph.AddPackage'); end; - - // update all missing dependencies - UpdateBrokenDependenciesToPackage(APackage); - - // activate define templates - if Assigned(APackage.DefineTemplates) then - APackage.DefineTemplates.Active:=true - else // By Juha: - // Happened when an old package with the same name was replaced. Cannot reproduce. - DebugLn(['TLazPackageGraph.AddPackage: APackage.DefineTemplates=Nil']); - if Assigned(OnAddPackage) then - OnAddPackage(APackage); EndUpdate; end; @@ -2305,6 +2314,11 @@ var begin if pvPkgSearch in Verbosity then debugln(['Info: (lazarus) replacing package "'+OldPackage.Filename+'" with "'+NewPackage.Filename+'"']); + if OldPackage.IsUpdateLocked then + begin + OldPackage.WriteUpdateLocks('TLazPackageGraph.ReplacePackage'); + raise Exception.Create('20240913140848'); + end; BeginUpdate(true); // save flags OldInstalled:=OldPackage.Installed; @@ -6010,6 +6024,13 @@ begin if SysUtils.CompareText(OldPackage.Name,NewPackage.Name)<>0 then RaiseGDBException('TLazPackageGraph.PackageCanBeReplaced'); + if OldPackage.IsUpdateLocked then + begin + OldPackage.WriteUpdateLocks('TLazPackageGraph.PackageCanBeReplaced Old'); + debugln(['Error: (lazarus) TLazPackageGraph.PackageCanBeReplaced ',OldPackage.IDAsString,' IsUpdateLocked']); + exit(false); + end; + Result:=true; end; @@ -6159,8 +6180,9 @@ begin //debugln(['TLazPackageGraph.OpenDependency checking preferred Prefer=',PreferredFilename]); if (PreferredFilename<>'') and ((Dependency.RequiredPackage=nil) - or ((Dependency.RequiredPackage.FindUsedByDepPrefer(Dependency)=nil) - and (CompareFilenames(PreferredFilename,Dependency.RequiredPackage.Filename)<>0))) + or ((not Dependency.RequiredPackage.IsUpdateLocked) + and (CompareFilenames(PreferredFilename,Dependency.RequiredPackage.Filename)<>0)) + and (Dependency.RequiredPackage.FindUsedByDepPrefer(Dependency)=nil) ) then begin if pvPkgSearch in Verbosity then debugln(['Info: (lazarus) Open dependency ['+Dependency.PackageName+']: trying resolved preferred filename: "'+PreferredFilename+'" ...']); @@ -6402,31 +6424,34 @@ begin // -> create a broken package BrokenPackage:=TLazPackage.CreateAndClear; with BrokenPackage do begin - BeginUpdate; - Missing:=true; - UserReadOnly:=true; - Name:=Dependency.PackageName; - Filename:=''; - Version.SetValues(0,0,0,0); - Author:='?'; - License:='?'; - AutoUpdate:=pupManually; - Description:=lisPkgSysThisPackageIsInstalledButTheLpkFileWasNotFound; - PackageType:=lptDesignTime; - Installed:=pitStatic; - AutoInstall:=pitNope; - if IsBasePkg then - AutoInstall:=pitStatic - else + BeginUpdate('TLazPackageGraph.OpenInstalledDependency'); + try + Missing:=true; + UserReadOnly:=true; + Name:=Dependency.PackageName; + Filename:=''; + Version.SetValues(0,0,0,0); + Author:='?'; + License:='?'; + AutoUpdate:=pupManually; + Description:=lisPkgSysThisPackageIsInstalledButTheLpkFileWasNotFound; + PackageType:=lptDesignTime; + Installed:=pitStatic; AutoInstall:=pitNope; - CompilerOptions.UnitOutputDirectory:=''; + if IsBasePkg then + AutoInstall:=pitStatic + else + AutoInstall:=pitNope; + CompilerOptions.UnitOutputDirectory:=''; - // add lazarus registration unit path - UsageOptions.UnitPath:=''; + // add lazarus registration unit path + UsageOptions.UnitPath:=''; - Modified:=false; - OnModifySilently:=@PkgModify; - EndUpdate; + Modified:=false; + OnModifySilently:=@PkgModify; + finally + EndUpdate('TLazPackageGraph.OpenInstalledDependency'); + end; end; AddPackage(BrokenPackage); //DebugLn('TLazPackageGraph.OpenInstalledDependency ',BrokenPackage.IDAsString,' ',dbgs(ord(BrokenPackage.AutoInstall))); diff --git a/packager/addfiletoapackagedlg.pas b/packager/addfiletoapackagedlg.pas index fa33757d87..44fffd00b8 100644 --- a/packager/addfiletoapackagedlg.pas +++ b/packager/addfiletoapackagedlg.pas @@ -146,15 +146,18 @@ begin end; // ok -> add file to package - APackage.BeginUpdate; - NewUnitPaths:=''; - NewIncPaths:=''; - APackage.AddFileByName(aFilename, NewUnitPaths, NewIncPaths); - // extend unit and include search path - if not APackage.ExtendUnitSearchPath(NewUnitPaths) then exit; - if not APackage.ExtendIncSearchPath(NewIncPaths) then exit; - if APackage.Editor<>nil then APackage.Editor.UpdateAll(true); - APackage.EndUpdate; + APackage.BeginUpdate('TAddFileToAPackageDialog.OkButtonClick'); + try + NewUnitPaths:=''; + NewIncPaths:=''; + APackage.AddFileByName(aFilename, NewUnitPaths, NewIncPaths); + // extend unit and include search path + if not APackage.ExtendUnitSearchPath(NewUnitPaths) then exit; + if not APackage.ExtendIncSearchPath(NewIncPaths) then exit; + if APackage.Editor<>nil then APackage.Editor.UpdateAll(true); + finally + APackage.EndUpdate('TAddFileToAPackageDialog.OkButtonClick'); + end; ModalResult:=mrOk; finally