Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-11

Exception in CreateForm after conversion from Delphi

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frederic Da Vitoria

Hello,

I am converting a set of old small applications which I probably wrote in Delphi 1 or 2, first version of the sources I have dates from 1996, last version (the version I am converting to Lazarus) from 1999, probably last updated in Delphi 3

I already did the conversion once with Lazarus 1.2 RC1. This first conversion had to be redone because Lazarus signaled an error converting the .res file. I don't remember what I did exactly, but I finally got a conversion without the .res error.

Running the new application raised an exception during creation of the main form (this will be explained below), so I decided to start again from a new conversion using Lazarus 20.1.0.14.

Lazarus 20.1.0.14 again signals an error while converting the .res file.

First compilation shows a few simple warnings about hiding inherited methods. I also get a hint about an exitProc which I'll explain later. So I remove them with hints and recompile. Lazarus hangs at that point, nothing in the output window, impossible to close the IDE (although it is responsive, I can for example open menus). I end up stopping Lazarus forcefully.

After reloading Lazarus, I get the same error about the .res file. I overwrite the .res with the one 1.2 RC1 generated, and now it compiles.

When running the application, I get again the same exception. So I decide to try to correct some code which is probably not valid any more: I move the contents of an exitProc to the finalization section and remove exitproc handling.

I still get the same exception as with 1.2 RC1: error 1407 in Win32WSControls.FinishCreateWindow. This is triggered by the first CreateForm which is in the dpr. If I comment out the CreateForm, I get the same exception for the next CreateForm. The debugger shows that upon calling CreateWindowEx, pClassName contains "Window".

I found on the Lazarus forum a discussion about error 1407 in 2009. The solution was to add Application.initialize in the lpr. But the converter did not create a lpr file, so I checked the dpr file and indeed found that Application.initialize was missing. Adding it solved my problem.

Why didn't the converter create a lpr file? Did I do something in the settings which caused this? I checked the conversion by 1.2 RC1, I did get a lpr, but it did not contain Application.initialize either. Shouldn't the converter add this line?

What are those .res conversion errors? The only reference I found is in the Code_Conversion_Guide, but it seems quite outdated, and I could not find reference to the resources files in the converter documentation.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131121/604e5a88/attachment.html>
Juha Manninen
to Frederic Da Vitoria
Frederic Da Vitoria wrote
Why didn't the converter create a lpr file? What are those .res conversion errors?

Hard to say without seeing and testing your code.

Please forget Lazarus 1.0.14 if you have problems with converter. It works better in Lazarus 1.2 RC1 or trunk.
Then please create a bug report with example code to reproduce it.

Juha

Frederic Da Vitoria
to Juha Manninen

2013/11/21 Juha Manninen

Show quoted text 11 lines
On Thu, Nov 21, 2013 at 1:13 PM, Frederic Da Vitoria wrote: > Why didn't the converter create a lpr file? > What are those .res conversion errors? Hard to say without seeing and testing your code. Please forget Lazarus 1.0.14 if you have problems with converter. It works better in Lazarus 1.2 RC1 or trunk. Then please create a bug report with example code to reproduce it.

OK, I'll try to reduce the project to it's minimum. Not very easy because all I have now is Delphi6, I hope this won't silently correct the problem. Well, if needed, I still have the older CDROMS, I hope they will install in my XP virtual machine.

One bug report? Do you think these issues could be related? Or should I create one report for the lpr+Initialize issue and one report for the .res?

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131121/5e337df0/attachment.html>
Juha Manninen
to Frederic Da Vitoria
Frederic Da Vitoria wrote
One bug report? Do you think these issues could be related? Or should I create one report for the lpr+Initialize issue and one report for the .res?

Let's start with one report.
If you can provide a project that triggers the problem, I will test it.

Juha

Frederic Da Vitoria
to Juha Manninen

2013/11/21 Juha Manninen

Show quoted text 9 lines
On Thu, Nov 21, 2013 at 11:01 PM, Frederic Da Vitoria wrote: > One bug report? Do you think these issues could be related? Or should I > create one report for the lpr+Initialize issue and one report for the .res? Let's start with one report. If you can provide a project that triggers the problem, I will test it.

I added the issue. http://mantis.freepascal.org/view.php?id=25354

During my tests, I had a new issue with the converter, which I did not include in Mantis as it seemed distinct. Here is my directory setup:
- d:\Delphi\Lazarus_Tests\Memo1_bak contains the files in Delphi version. This is where I edit the files with Notepad++ in order to remove parts of code before copying them to the next folder.
d:\Delphi\Lazarus_Tests\Memo1_bak\$ contains the files (units) which I have removed from the original source.
- d:\Delphi\Lazarus_Tests\Memo1 is the conversion folder, where I copy the files from above and where the application I ask Lazarus to convert is.

During one of the code cleaning iterations, I hadn't cleaned properly Memo1_bak so that the uses still contained a reference to a unit which I thought I had removed from everywhere. I had removed the unit source. My new issue is that the converter found the unit in
d:\Delphi\Lazarus_Tests\Memo1_bak\$ and converted it! As you can see, my source does not contain any reference to Memo1_bak, I never opened any file in d:\Delphi\Lazarus_Tests\Memo1_bak nor
d:\Delphi\Lazarus_Tests\Memo1_bak\$ with Lazarus, so I don't know how and why it searched there.

One last comment: As far as I can see, when checking "Delphi support", the converter does not rename the .dpr as .lpr and it keeps the .dfm files. I understand why the converter does this, but I suggest it should be mentioned in the documentation.

I had at one point a problem with the dfm files: the project wouldn't compile because they were binary. So I opened the Delphi original project in Delphi 6 and wrote the dfm from binary to text. My guess is that for some reason, the converter did not write the lfm copies, so that the only way to compile was using the dfm, which were binary. I am unable to reproduce the issue (the converter now always writes the lfm files) and sorry, I did not keep a copy of the conversion results, so this remark is only for the record.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131122/65c146c1/attachment.html>
Juha Manninen
to Frederic Da Vitoria
Frederic Da Vitoria wrote
... with Lazarus, so I don't know how and why it searched there.

Ok, this is the fundamental cause of your problems. The converter searches for unit files from project's sibling directories, meaning the directories that are below its parent dir. Don't place copies of the same project there.
This is a useful feature because many projects include their libraries there and they are found automatically.

Test again without those copied dirs and let me know what happens.

I had at one point a problem with the dfm files: the project wouldn't compile because they were binary.

The converter is able to convert from old binary DFM to text LFM. It should not cause problems.

Juha

Frederic Da Vitoria
to Juha Manninen

2013/11/22 Juha Manninen

Show quoted text 13 lines
On Fri, Nov 22, 2013 at 1:15 PM, Frederic Da Vitoria wrote: > ... with Lazarus, so I don't know how and why it searched there. Ok, this is the fundamental cause of your problems. The converter searches for unit files from project's sibling directories, meaning the directories that are below its parent dir. Don't place copies of the same project there. This is a useful feature because many projects include their libraries there and they are found automatically. Test again without those copied dirs and let me know what happens.

Sorry to disappoint your hopes, but after copying the Delphi sources to c:\temp\lazarus_test_memo (no, temp does not contain any other pascal sources, and C: only contains the fpc/lazarus binaries in different subdirectories), I get the same results: issue with .res file and after commenting out the $R *.res directive, running the application triggers an exception.

... and this time I managed to upload the source successfully :-P

Show quoted text 6 lines
I had at one point a problem with the dfm files: the project wouldn't > compile because they were binary. The converter is able to convert from old binary DFM to text LFM. It should not cause problems.

As I explained, I suppose that for some reason, the LFM files were not created that time. I can't be sure because the directory where this happened has been emptied and recreated numerous times since, but this is the best explanation I can suggest. So this LFM problem would be a sporadic and probably unrelated issue. I only mentioned it because my supposition could be wrong and maybe telling this could help you find where the main problem comes from.

Frederic Da Vitoria (davitof) Membre de l'April - ? promouvoir et d?fendre le logiciel libre ? - http://www.april.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131122/a3f49e35/attachment.html>