View Issue Details

IDProjectCategoryView StatusLast Update
0022630LazarusConverterpublic2012-10-12 20:05
ReporteroceanAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0022630: Converting dpr tries to convert Delphi sources too
DescriptionHappens even trying to convert empty project. It takes some time and then I get attached error message.

Where does it get that path anyway?

I guess error message hits bug 22603, but I don't think it should attempt to convert forms.pas

(I can attach sample project, but I think you need to have Delphi installed to hit this)

Note, converting unit works, I only get this when trying to convert project.
TagsNo tags attached.
Fixed in Revisionr38276, r38290
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • bug4.jpg (50,347 bytes)
    bug4.jpg (50,347 bytes)
  • converter.donotscanroot.diff (1,266 bytes)
    Index: converter/convertdelphi.pas
    ===================================================================
    --- converter/convertdelphi.pas	(revision 38127)
    +++ converter/convertdelphi.pas	(working copy)
    @@ -398,8 +398,23 @@
     procedure TCacheUnitsThread.Execute;
     // This assumes that cache is not used while updating it.
     // The main GUI thread must wait for this thread before starting conversion.
    +  function IsRootPath(APath: String): Boolean;
    +  //crude function, it maybe needs support for UNC drives
    +  begin
    +    {$ifdef windows}
    +    Result := ((Length(APath) = 3) and (APath[1] in ['a'..'z','A'..'Z']) and (APath[2] = ':') and (APath[3] = PathDelim))
    +              or (APath = PathDelim);
    +    {$else}
    +    Result := (APath = PathDelim);
    +    {$endif}
    +  end;
    +
     begin
    -  fConverter.CacheUnitsInPath(fPath); // Scan for unit files.
    +  //If a project is in a subfolder of the root, fPath will be root path
    +  //in this case do not search the entire drive, or we may find Borland VCL files
    +  //like forms.pas and convert these too
    +  //debugln('TCacheUnitsThread.Execute: fPath = ',fPath,' IsRootPath = ',DbgS(IsRootPath(fPath)));
    +  if not IsRootPath(fPath) then fConverter.CacheUnitsInPath(fPath); // Scan for unit files.
     end;
     
     { TConvertDelphiUnit }
    
  • converter.donotscanroot.2.diff (822 bytes)
    Index: converter/convertdelphi.pas
    ===================================================================
    --- converter/convertdelphi.pas	(revision 38276)
    +++ converter/convertdelphi.pas	(working copy)
    @@ -401,13 +401,14 @@
     
       function IsRootPath(APath: String): Boolean;
       //crude function, it maybe needs support for UNC drives
    +  var
    +    D: String;
    +    Len: Integer;
       begin
    -    {$ifdef windows}
    -    Result := ((Length(APath) = 3) and (APath[1] in ['a'..'z','A'..'Z']) and (APath[2] = ':') and (APath[3] = PathDelim))
    -              or (APath = PathDelim);
    -    {$else}
    -    Result := (APath = PathDelim);
    -    {$endif}
    +    D := ExtractFileDrive(APath);
    +    Len := Length(D);
    +    System.Delete(APath, 1, Len);
    +    Result := (Length(APath) = 1) and (APath[1] in AllowDirectorySeparators);
       end;
     
     begin
    

Relationships

related to 0022603 closedBart Broersma Createrelativepath doesn't work 
related to 0022677 closedJuha Manninen Converter does not handle (alias) Wintypes and Winproc units in old Delphi projects 

Activities

2012-08-13 09:13

 

bug4.jpg (50,347 bytes)
bug4.jpg (50,347 bytes)

Juha Manninen

2012-08-18 22:13

developer   ~0061705

Last edited: 2012-08-18 22:21

Your program is in directory C:\Bug4, right?
Could you try moving it one level down in directory hierarchy, for example to C:\SW\Bug4 or whatever.

The converter scans in a background thread all directories under the converted project's parent directory, searching for pascal source files. Many projects have library sources organized that way.
Obviously it creates a problem if your project is just under C:\ root.
I again tested poorly on Windows, on *nix systems it seldom creates a problem.

If you want to look at (and maybe fix) the code creating the problem, check the class TCacheUnitsThread in unit ConvertDelphi, in converter directory.
Its constructor has :
  fPath:=TrimFilename(aBasePath+'..'+DirectorySeparator);
The fix would be to check if the resulting path is the root (like C:\) directory, and then not do anything in the Execute method.

Suomalainen käyttöliittymä! Joku siis käyttää sitä. Hyvä. :)

Bart Broersma

2012-08-19 00:02

developer   ~0061707

Q: Does Delphi somewhere store (in the project file) where include files, libraries and other user files are stored (like lazarus does), so we can restrict the search to those user directories?

ocean

2012-08-19 09:24

reporter   ~0061711

You are correct, C:/sw/bug4/ works, and C:/bug4/ doesn't. Main problem is searching root, it might take long time and IDE seems unresponsive all this time.

Also if there weren't that error, it would really? modify the original forms.pas in Delphi source directory

Juha Manninen

2012-08-19 09:58

developer   ~0061712

Last edited: 2012-08-19 09:59

Bart, Delphi stores the project settings to a .dof file IIRC.
However, most often the library search paths are defined in global settings instead of project settings. When you download a Delphi project, the required library sources may already be included in separate libraries. That is why I added the feature of scanning the ../. directory.
You can use that logic and copy more library sources yourself. So yes, it is a useful feature but the bug must be fixed of course.

ocean, yes it tries to convert forms.pas.
Could you please create and test a fix for it on Windows. See my earlier comment about TCacheUnitsThread.

2012-08-19 15:31

 

converter.donotscanroot.diff (1,266 bytes)
Index: converter/convertdelphi.pas
===================================================================
--- converter/convertdelphi.pas	(revision 38127)
+++ converter/convertdelphi.pas	(working copy)
@@ -398,8 +398,23 @@
 procedure TCacheUnitsThread.Execute;
 // This assumes that cache is not used while updating it.
 // The main GUI thread must wait for this thread before starting conversion.
+  function IsRootPath(APath: String): Boolean;
+  //crude function, it maybe needs support for UNC drives
+  begin
+    {$ifdef windows}
+    Result := ((Length(APath) = 3) and (APath[1] in ['a'..'z','A'..'Z']) and (APath[2] = ':') and (APath[3] = PathDelim))
+              or (APath = PathDelim);
+    {$else}
+    Result := (APath = PathDelim);
+    {$endif}
+  end;
+
 begin
-  fConverter.CacheUnitsInPath(fPath); // Scan for unit files.
+  //If a project is in a subfolder of the root, fPath will be root path
+  //in this case do not search the entire drive, or we may find Borland VCL files
+  //like forms.pas and convert these too
+  //debugln('TCacheUnitsThread.Execute: fPath = ',fPath,' IsRootPath = ',DbgS(IsRootPath(fPath)));
+  if not IsRootPath(fPath) then fConverter.CacheUnitsInPath(fPath); // Scan for unit files.
 end;
 
 { TConvertDelphiUnit }

Bart Broersma

2012-08-19 15:32

developer   ~0061725

Possible patch uploaded.
Only tested on Windows.

Juha Manninen

2012-08-19 21:52

developer   ~0061727

I applied the patch, thanks.
I only wonder if there is a function like IsRootPath already somewhere in FPC's libraries. The platform specific code should be in libraries.

Bart Broersma

2012-08-19 23:40

developer   ~0061730

@Juha: I tried to find something like that but didn't.
I'll ask on mailinglist.

Bart Broersma

2012-08-20 00:53

developer   ~0061740

Last edited: 2012-08-20 00:55

@Juha: Maybe I should not re-open, but I wrote a different IsRootPath function that doesn't need to be ifdef-ed, it relies on fpc's RTL functions.
See attached converter.donotscanroot.2.diff (against r38276).

2012-08-20 00:54

 

converter.donotscanroot.2.diff (822 bytes)
Index: converter/convertdelphi.pas
===================================================================
--- converter/convertdelphi.pas	(revision 38276)
+++ converter/convertdelphi.pas	(working copy)
@@ -401,13 +401,14 @@
 
   function IsRootPath(APath: String): Boolean;
   //crude function, it maybe needs support for UNC drives
+  var
+    D: String;
+    Len: Integer;
   begin
-    {$ifdef windows}
-    Result := ((Length(APath) = 3) and (APath[1] in ['a'..'z','A'..'Z']) and (APath[2] = ':') and (APath[3] = PathDelim))
-              or (APath = PathDelim);
-    {$else}
-    Result := (APath = PathDelim);
-    {$endif}
+    D := ExtractFileDrive(APath);
+    Len := Length(D);
+    System.Delete(APath, 1, Len);
+    Result := (Length(APath) = 1) and (APath[1] in AllowDirectorySeparators);
   end;
 
 begin

Bart Broersma

2012-08-20 13:49

developer   ~0061752

PM.
> I'll ask on mailinglist.
Michael said (on mailinglist): "There is no such function."

Juha Manninen

2012-08-21 00:07

developer   ~0061779

Applied, thanks.
Looks good.

ocean

2012-10-12 20:05

reporter   ~0063103

Thanks!

Issue History

Date Modified Username Field Change
2012-08-13 09:13 ocean New Issue
2012-08-13 09:13 ocean Status new => assigned
2012-08-13 09:13 ocean Assigned To => Juha Manninen
2012-08-13 09:13 ocean File Added: bug4.jpg
2012-08-13 09:13 ocean Widgetset => Win32/Win64
2012-08-13 23:57 Juha Manninen Relationship added related to 0022603
2012-08-18 22:13 Juha Manninen Note Added: 0061705
2012-08-18 22:21 Juha Manninen Note Edited: 0061705
2012-08-19 00:02 Bart Broersma Note Added: 0061707
2012-08-19 09:24 ocean Note Added: 0061711
2012-08-19 09:58 Juha Manninen Note Added: 0061712
2012-08-19 09:59 Juha Manninen Note Edited: 0061712
2012-08-19 15:31 Bart Broersma File Added: converter.donotscanroot.diff
2012-08-19 15:32 Bart Broersma Note Added: 0061725
2012-08-19 21:52 Juha Manninen Fixed in Revision => r38276
2012-08-19 21:52 Juha Manninen LazTarget => -
2012-08-19 21:52 Juha Manninen Status assigned => resolved
2012-08-19 21:52 Juha Manninen Resolution open => fixed
2012-08-19 21:52 Juha Manninen Note Added: 0061727
2012-08-19 23:40 Bart Broersma Note Added: 0061730
2012-08-20 00:53 Bart Broersma Status resolved => assigned
2012-08-20 00:53 Bart Broersma Resolution fixed => reopened
2012-08-20 00:53 Bart Broersma Note Added: 0061740
2012-08-20 00:54 Bart Broersma File Added: converter.donotscanroot.2.diff
2012-08-20 00:55 Bart Broersma Note Edited: 0061740
2012-08-20 13:49 Bart Broersma Note Added: 0061752
2012-08-21 00:07 Juha Manninen Fixed in Revision r38276 => r38276, r38290
2012-08-21 00:07 Juha Manninen Status assigned => resolved
2012-08-21 00:07 Juha Manninen Resolution reopened => fixed
2012-08-21 00:07 Juha Manninen Note Added: 0061779
2012-08-21 21:32 Juha Manninen Relationship added related to 0022677
2012-10-12 20:05 ocean Status resolved => closed
2012-10-12 20:05 ocean Note Added: 0063103