[Lazarus] RE : Still some problems withPackageEditingInterface.DoOpenPackageFile

Ludo Brands ludo.brands at free.fr
Mon Jan 9 10:12:21 CET 2012


> I'm doing now
> if PackageEditingInterface.FindPackageWithName(PkgName)<>nil then
>  
> PackageEditingInterface.DoOpenPackageFile(sDir+PkgName+'.lpk',
> [pofRevert],fa
> lse)
> else
>  
> PackageEditingInterface.DoOpenPackageFile(sDir+PkgName+'.lpk',
> [pofAddToRecen
> t],false);
> 
> but FindPackageWithName returns nil. What can I do?
> 

Found the solution but it looks "sub-optimal":

if PackageEditingInterface.FindPackageWithName(TLI.UnitName+'P')<>nil then
  begin
 
PackageEditingInterface.DoOpenPackageFile(sDir+TLI.UnitName+'P.lpk',[pofReve
rt],false);
  PackageEditingInterface.DoOpenPackageWithName(TLI.UnitName+'P',[],false);
  end
else
 
PackageEditingInterface.DoOpenPackageFile(sDir+TLI.UnitName+'P.lpk',[pofAddT
oRecent],false);

The DoOpenPackageFile with pofRevert is needed to reload the new package and
avoid the "disk file changed" warning. But in DoOpenPackageFile Apackage is
assigned but not Apackage.Editor, resulting in the editor not being opened.
Hence the DoOpenPackageWithName. 

Reason for FindPackageWithName not functioning correctly yesterday is
because of the package not being re-compiled correctly. I found out I need
to do a "Recompile Clean" when a unit of the package has changed. For one
reason or another, changing a unit in a package doesn't make it recompile
that unit. Is this a bug?

Ludo





More information about the Lazarus mailing list