diff --git a/components/onlinepackagemanager/opkman_serializablepackages.pas b/components/onlinepackagemanager/opkman_serializablepackages.pas index e92e8cc2e8..640c6e3a27 100644 --- a/components/onlinepackagemanager/opkman_serializablepackages.pas +++ b/components/onlinepackagemanager/opkman_serializablepackages.pas @@ -148,6 +148,7 @@ type constructor Create; reintroduce; destructor Destroy; override; public + function RefreshHasUpdate: Boolean; property Version: TPackageVersion read FVersion write FVersion; property Dependencies: TPackageDependencies read FDependencies write FDependencies; property PackageStates: TPackageStates read FPackageStates write FPackageStates; @@ -493,6 +494,15 @@ begin inherited Destroy; end; +function TLazarusPackage.RefreshHasUpdate: Boolean; +begin + FHasUpdate := (FUpdateVersion <> '') and (FInstalledFileVersion <> '') and + ( + ((not FForceNotify) and (FUpdateVersion > FInstalledFileVersion)) or + ((FForceNotify) and (FInternalVersion > FInternalVersionOld)) + ); +end; + { TMetaPackage } function TMetaPackage.GetDownloadable: Boolean; begin diff --git a/components/onlinepackagemanager/opkman_updates.pas b/components/onlinepackagemanager/opkman_updates.pas index 326de94704..04e1b7c985 100644 --- a/components/onlinepackagemanager/opkman_updates.pas +++ b/components/onlinepackagemanager/opkman_updates.pas @@ -303,11 +303,7 @@ begin LazarusPkg.ForceNotify := FXML.GetValue(SubPath + 'ForceNotify', False); LazarusPkg.InternalVersion := FXML.GetValue(SubPath + 'InternalVersion', 0);; LazarusPkg.InternalVersionOld := FXML.GetValue(SubPath + 'InternalVersionOld', 0); - LazarusPkg.HasUpdate := (LazarusPkg.UpdateVersion <> '') and (LazarusPkg.InstalledFileVersion <> '') and - ( - ((not LazarusPkg.ForceNotify) and (LazarusPkg.UpdateVersion > LazarusPkg.InstalledFileVersion)) or - ((LazarusPkg.ForceNotify) and (LazarusPkg.InternalVersion > LazarusPkg.InternalVersionOld)) - ); + LazarusPkg.RefreshHasUpdate; if not HasUpdate then HasUpdate := LazarusPkg.HasUpdate; end; @@ -358,23 +354,21 @@ var I: Integer; HasUpdate: Boolean; LazarusPkg: TLazarusPackage; + UpdLazPkgs: TUpdateLazPackages; begin HasUpdate := False; AMetaPackage.DownloadZipURL := FUpdatePackage.FUpdatePackageData.DownloadZipURL; AMetaPackage.DisableInOPM := FUpdatePackage.FUpdatePackageData.DisableInOPM; for I := 0 to FUpdatePackage.FUpdateLazPackages.Count - 1 do begin - LazarusPkg := AMetaPackage.FindLazarusPackage(TUpdateLazPackages(FUpdatePackage.FUpdateLazPackages.Items[I]).Name); + UpdLazPkgs := TUpdateLazPackages(FUpdatePackage.FUpdateLazPackages.Items[I]); + LazarusPkg := AMetaPackage.FindLazarusPackage(UpdLazPkgs.Name); if LazarusPkg <> nil then begin - LazarusPkg.UpdateVersion := TUpdateLazPackages(FUpdatePackage.FUpdateLazPackages.Items[I]).Version; - LazarusPkg.ForceNotify := TUpdateLazPackages(FUpdatePackage.FUpdateLazPackages.Items[I]).ForceNotify; - LazarusPkg.InternalVersion := TUpdateLazPackages(FUpdatePackage.FUpdateLazPackages.Items[I]).InternalVersion; - LazarusPkg.HasUpdate := (LazarusPkg.UpdateVersion <> '') and (LazarusPkg.InstalledFileVersion <> '') and - ( - ((not LazarusPkg.ForceNotify) and (LazarusPkg.UpdateVersion > LazarusPkg.InstalledFileVersion)) or - ((LazarusPkg.ForceNotify) and (LazarusPkg.InternalVersion > LazarusPkg.InternalVersionOld)) - ); + LazarusPkg.UpdateVersion := UpdLazPkgs.Version; + LazarusPkg.ForceNotify := UpdLazPkgs.ForceNotify; + LazarusPkg.InternalVersion := UpdLazPkgs.InternalVersion; + LazarusPkg.RefreshHasUpdate; if not HasUpdate then HasUpdate := LazarusPkg.HasUpdate; end;