[Lazarus] Challenge of converting a Delphi project

Samuel Herzog sam_herzog at yahoo.com
Mon May 3 21:48:24 CEST 2010


Hi Juha,

I compiled ess-model from your git repo on win32.
Had to add 3 TODO's to make it compilable for win32.

Tried to commit the changes to your git-repo.
It was the first time I used git and it looks like my user-settings were not very good.
The name used to commit was "master". I have changed my settings so next time it should be better.

That's it for the moment. Will play around with the sources as soon as I have some spare time.

Thank you very much for your incredible work you did for the DelphiToLazarus Convertion stuff !!!!

Regards,

Sam


--- Juha Manninen <juha.manninen at phnet.fi> schrieb am Mo, 3.5.2010:

Von: Juha Manninen <juha.manninen at phnet.fi>
Betreff: [Lazarus] Challenge of converting a Delphi project
An: lazarus at lists.lazarus.freepascal.org
Datum: Montag, 3. Mai, 2010 13:52 Uhr

Hi

I have been converting EssModel Delphi program, partly as an exercise and 
partly because it could develop into a useful program or component.
It is a reverse engineering class diagram tool.

I am facing more problems than expected. This is not related to Delphi 
converter in Lazarus but to the manual editing after it.

First, the code uses a trick. It typecast controls like TForm to a local 
TCrackControl just to reach the protected TControl.OnMouseDown and such.

  type
    TCrackControl = class(TControl);  // <-- empty local class
  var
    found: TControl;
    cc: TCrackControl;

and later:
  // 'found' can be TForm or anything.
  cc:=TCrackControl(found);  // <-- error
  cc.OnMouseDown := ...

It gives 'RunError(219)', and the whole Lazarus may become unstable.
The typecast is actually OK because the controls inherit from TControl and 
OnMouseDown is defined there. According to Mattias this system is even used in 
Lazarus itself. In a small test project the same system worked for me, too.
???

The program used interfaces heavily, actually in a clever way. I thought they 
cause the above problem and changed the code quite much to get rid of 
interfaces. No difference, it still doesn't work.

Next problem: I noticed there are TActions defined in a DataModule which is 
created in MainForm.OnActivate handler, and the actions are used in form's 
menu and button. I thought it causes problems and I copied everything from 
DataModule to MainForm. I set the actions carefully like they were before and 
now menu items work but open-button does not. The exact same action is 
triggered by menuitem but not by button!
So, this refactoring didn't solve any problems but created a new one.

And then: before the program closes it writes recent files to registry. It 
gives an error when writing a string, although I can find the "reg.xml" file 
it wrote. The same thing works in my small test project without errors.

All the program's behavior is defined in project file, pascal source code and 
form files. Am I correct?
So, WHAT CAN CAUSE SUCH PROBLEMS? I have used many many hours already trying 
to solve this.
The program itself is not very important now, I could as well forget it.
I just feel uncomfortable when there are errors which I can't explain.
Besides I am supposed to improve Delphi converter but now I am not even able 
to convert a program myself...

My tests happened on Linux, with GTK2 and QT. If someone likes to look at the 
code, please do this:

  $ git clone git://github.com/JuhaManninen/Pascal.git

It is not big.
At least it should be easy to verify the MainForm.OpenButton doesn't work 
while it should, even though the program hasn't done anything yet.


Regards,
Juha

--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100503/a9c8f7be/attachment-0004.html>


More information about the Lazarus mailing list