View Issue Details

IDProjectCategoryView StatusLast Update
0022677LazarusConverterpublic2012-09-30 22:04
ReporterBart BroersmaAssigned ToJuha Manninen 
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindowOS VersionWin7
Product Version1.1 (SVN)Product Buildr38127  
Target VersionFixed in Version1.1 (SVN) 
Summary0022677: Converter does not handle (alias) Wintypes and Winproc units in old Delphi projects
DescriptionVery old Delphi units may still use the (no longer existing) Wintypes and Winproc units.
Delphi silently ignores these and uses Windows unit as an alias.
The converter leaves them in place.

If the user selects multi-platform, the converter should probably drop these units in the uses clause, if the user wants delphi compatibility only, then they should be replaced by Windows unit.
TagsNo tags attached.
Fixed in Revisionr38903
LazTarget-
Widgetset
Attached Files

Relationships

related to 0022630 closedJuha Manninen Converting dpr tries to convert Delphi sources too 

Activities

Juha Manninen

2012-08-19 22:21

developer   ~0061728

There are settings to remove those units.

  MapReplacement('WinTypes', '');
  MapReplacement('WinProcs', '');

Does it not work? Please upload a test project.

2012-08-19 23:46

 

pasparser_bron.zip (9,345 bytes)

Bart Broersma

2012-08-19 23:54

developer   ~0061731

Last edited: 2012-08-20 00:05

See attached pasparser_bron.zip.

This was my test project for testing the converter issue 0022630
The unit nldlg32.pas has wintypes and winprocs in it's uses clause.

If I convert the project (Tools -> Convert Delphi Project to Lazarus Project), using default settings in the dialog, it will leave the wintypes and windproc in place.
A snippet after conversion:
=============================================
unit nldlg32;

{$MODE Delphi}

interface

uses SysUtils, WinTypes, WinProcs, Messages, Classes,
     Graphics, Controls, Forms, Dialogs, StdCtrls,
     ExtCtrls, Buttons;
=============================================



The odd thing is that, if I only convert this unit (Tools -> Convert Delphi Unit to Lazarus Unit), again using default settings in the dialog, now the wintypes and windproc units are removed from the uses clause.

Now it looks like this:
=============================================
unit nldlg32;

{$MODE Delphi}

interface

uses SysUtils, Messages, Classes,
     Graphics, Controls, Forms, Dialogs, StdCtrls,
     ExtCtrls, Buttons;
=============================================

Bart Broersma

2012-08-22 14:19

developer   ~0061808

Now I understand what is happening.
My assumption was that when converting a project, it would also convert all units the project uses.
However it only seems to convert the units that are in the uses section of the .dpr file.
So when converting my attached test project, it actually does _not_ try to convert the nldlg32.pas unit at all (used in the main form: pasparser.pas).

Is this by design (which is confusing to me, from the perspective of the end user), or is this an oversight?

Juha Manninen

2012-08-22 19:53

developer   ~0061813

Yes it should be converted.
The problem IMO is that those Windows specific units are not reported as missing when you work on Windows. When a unit is not missing, the converter doesn't do anything for it.
There is a hack to deal with those units, I already improved it but didn't commit yet. I will do it later tonight with other commits...

Your uses section does not have Winodws unit at all. How come?

Juha Manninen

2012-08-23 08:25

developer   ~0061821

Please test with r38343.
See the new function IsWinSpecificUnit and how it is used.
If the Windows unit is missing completely, maybe we need to replace those other units with 'LCLIntf, LCLType, LMessages'

Bart Broersma

2012-08-23 23:48

developer   ~0061845

> Your uses section does not have Winodws unit at all. How come?
IIRC Delphi silently replaces Wintypes and Winprocs with Windows.
It's a very old unit...

> If the Windows unit is missing completely, maybe we need to replace those
> other units with 'LCLIntf, LCLType, LMessages'
Probably yes.

I'll re-test soon and report back to you.

Bart Broersma

2012-08-26 11:34

developer   ~0061907

Tetsed with r38343, converting the pasparser.dpr project.
It still does not convert the nldlg32.pas (nor the misc.pas) unit (at least TUsedUnitsTool.Prepare is never called for any of these units), it only converts pasparser.dpr and upasparser.pas units.

Juha Manninen

2012-09-29 16:56

developer   ~0062736

> It still does not convert the nldlg32.pas ...

I finally fixed this is r38903. Please test again.
The reason was that units in project directory which are not part of the project were not reported as missing and thus not converted.

r38904 also replaces "WinTypes" and "WinProcs" the same way as "Windows" is replaced.
See if it is correct.

Bart Broersma

2012-09-29 22:56

developer   ~0062745

It now converts both misc.pas and nldlg32.pas

As a side note: I saw it replaces any call to Shellexecute with a call to OpenDocument, which is wrong in this particular unit (misc.pas).
Can this be controlled by the user somehow?

Anyhow. You can resolve this issue as fixed.

Thanks.

Juha Manninen

2012-09-30 00:45

developer   ~0062751

You can edit Function Replacements in the converter settings dialog.
Disabling the WindowsAPI category is one handy way.
You cannot disable it for one unit only, the setting affects all units.

We can continue discussing it on mailing list if needed.

Bart Broersma

2012-09-30 22:04

developer   ~0062783

Thanks.

Issue History

Date Modified Username Field Change
2012-08-19 15:43 Bart Broersma New Issue
2012-08-19 15:43 Bart Broersma Status new => assigned
2012-08-19 15:43 Bart Broersma Assigned To => Juha Manninen
2012-08-19 15:43 Bart Broersma LazTarget => -
2012-08-19 22:21 Juha Manninen Note Added: 0061728
2012-08-19 22:21 Juha Manninen Status assigned => feedback
2012-08-19 23:46 Bart Broersma File Added: pasparser_bron.zip
2012-08-19 23:54 Bart Broersma Note Added: 0061731
2012-08-20 00:05 Bart Broersma Note Edited: 0061731
2012-08-21 21:32 Juha Manninen Relationship added related to 0022630
2012-08-22 14:19 Bart Broersma Note Added: 0061808
2012-08-22 19:53 Juha Manninen Note Added: 0061813
2012-08-23 08:25 Juha Manninen Note Added: 0061821
2012-08-23 23:48 Bart Broersma Note Added: 0061845
2012-08-26 11:34 Bart Broersma Note Added: 0061907
2012-09-29 16:56 Juha Manninen Note Added: 0062736
2012-09-29 22:56 Bart Broersma Note Added: 0062745
2012-09-30 00:45 Juha Manninen Fixed in Revision => r38903
2012-09-30 00:45 Juha Manninen Status feedback => resolved
2012-09-30 00:45 Juha Manninen Resolution open => fixed
2012-09-30 00:45 Juha Manninen Note Added: 0062751
2012-09-30 22:04 Bart Broersma Status resolved => closed
2012-09-30 22:04 Bart Broersma Note Added: 0062783
2012-09-30 22:04 Bart Broersma Fixed in Version => 1.1 (SVN)