Recent

Author Topic: [SOLVED] IDE freezing on opening project converted from Delphi under Linux  (Read 1248 times)

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Dear ALL,

Some years ago, I developed a text analysis program in FPC/Lazarus, which in turn was converted from a still older version (partially) implemented in Delphi 4.0 back in the 1990's.

Using the built-in conversion tool, I was able to convert the project into Lazarus and it compiles and runs very well under MS-Windows (both 7 and 10).

However, when I attempt to open the converted project under Linux (Mint 19 and Lubuntu 16, using either Lazarus 1.97 and Lazarus 2.0), a strange problem arises: the project opens, but IDE freezes and nothing else works until I kill the process to close the IDE.

I would like to have a Linux version of this application (after all, that is one of the my great points of FPC/Lazarus), but cannot see what maybe wrong with the converted project (all the forms appears OK).

Could someone help me to crack this (hopefully not so tough) nut?

The full source code is here: https://github.com/maurobio/libro

Many thanks in advance!
« Last Edit: June 07, 2023, 02:35:57 pm by maurobio »
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #1 on: June 06, 2023, 10:00:07 pm »
Quote
using either Lazarus 1.97 and Lazarus 2.0

Very old....

You will at least in your Windows IDE (if that is newer) have  to enable "compatible project files". Because the format changed.

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #2 on: June 06, 2023, 10:11:55 pm »
Hi, @Martin_fr!

Thanks for your fast reply!

Quote
Very old....

I am now in fact running Lazarus 2.0.12 under Mint 19 Cinnamon and MATE. I prefer to stick to versions of both the development tool and the operating system that work smoothly to me instead of upgrading often and risking break everything, leading to unnecessary rises in blood pressure...

Quote
You will at least in your Windows IDE (if that is newer) have  to enable "compatible project files". Because the format changed.

I am not sure if I have understood this. I have no problems in the Windows IDE, it freezes only under Linux. I suspect that something went awry in the project conversion of the forms but it is undetected by Windows.

With warmest regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #3 on: June 06, 2023, 11:08:50 pm »
You get the freeze when opening the project? Not when running/debugging it?

If your Windows Lazarus is newer, the file format for lpi changed. So the old IDE will have issues (should give an error, but well).

There is somewhere a setting to write compatible project files... But I haven't looked in a long time. Not sure where exactly.

If something is wrong in the lfm => there is a setting not to open them when the project loads. (global options).

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #4 on: June 06, 2023, 11:42:18 pm »
Hi, @Martin_fr!

Quote
You get the freeze when opening the project? Not when running/debugging it?

Indeed, the project opens and the forms (there are two) are displayed fine. But when I attempt to compile the program, is raises an error in lines 500 of "ExSys.pas" (which is not called directly by the program) and then the IDE freezes. It can only be closed by killing the process.

No such problem occurs under Windows, where the program compiles and runs fine.

Very strange...

With warmest regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #5 on: June 07, 2023, 01:55:49 am »
I cloned and opened your project on Linux with Lazarus trunk.
Initially TAChartLazarusPkg, HistoryLazarus and FrameViewer09 were missing.
I installed TAChart first, then restarted Lazarus.
I got an error about missing HistoryFiles, clicked it and indeed Lazarus hanged. The splash screen image stayed visible, cursor was an hourglass, nothing responded.
However CPU load was near zero. A message box must have been behind the splash screen waiting for user action. I was able to move other windows and check it was not hiding behind them.
This is probably a GTK2 feature, it has problems with Z-order.

When I opened Lazarus first with another project and then switched to your Libro project, things worked as expected. There were message boxes but I could click them away.
Once HistoryLazarus and FrameViewer09 (HtmlViewer) were installed, there were no initial errors.
Compilation failed because a uses section has: Aliasv, StrLst, StrCount, VTxtStrm, VectStr
which do not exist.
Commenting them out gives other errors.

No "ExSys.pas", no hang during compilation. Everything works as expected once you get past the splash screen.
Please update your Lazarus, preferably try the development version which is heading for a new release soon.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #6 on: June 07, 2023, 03:30:52 am »
Hi, @JuhaManninen!

Thanks a lot for taking the time to look at my application.

Quote
I got an error about missing HistoryFiles, clicked it and indeed Lazarus hanged. The splash screen image stayed visible, cursor was an hourglass, nothing responded.

Is it possible that this particular component is causing problems under Linux? It does not seem probable because I use it on another FPC/Lazarus project which compiles and runs fine under both Windows and Linux.

Quote
When I opened Lazarus first with another project and then switched to your Libro project, things worked as expected. There were message boxes but I could click them away.

I will try this on my Linux system and see what happens.

Quote
Once HistoryLazarus and FrameViewer09 (HtmlViewer) were installed, there were no initial errors.
Compilation failed because a uses section has: Aliasv, StrLst, StrCount, VTxtStrm, VectStr
which do not exist.

That is because these units are part of the Vector Library which can be find here: http://torry.net/files/vcl/science/vector/achvectors.zip. This and all other dependencies are listed at the top of the Main.pas file in the application repository.

Quote
Please update your Lazarus, preferably try the development version which is heading for a new release soon.

I may try this, although I am never inclined to use development versions because stability is of prime importance.

With warmest regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #7 on: June 07, 2023, 09:57:16 am »
Is it possible that this particular component is causing problems under Linux? It does not seem probable because I use it on another FPC/Lazarus project which compiles and runs fine under both Windows and Linux.
It does not freeze Lazarus for sure.

Quote
That is because these units are part of the Vector Library which can be find here: http://torry.net/files/vcl/science/vector/achvectors.zip. This and all other dependencies are listed at the top of the Main.pas file in the application repository.
OK, you had your local path for it in project options. I downloaded it here and changed the path.
Oh boy, porting it requires some work. For example ExSys.pas has tons of IFDEFs for Windows / Linux, and the Linux part does not work. Such a unit should not be needed at all. FPC already provides cross-platform libraries which allows to write such code without any IFDEFs.
Somebody should properly port Vectors Library. Is the author Alexey A.Chernobaev still active?
Using another vector library / package is an option. I don't use one myself so I cannot give recommendations.

Quote
I may try this, although I am never inclined to use development versions because stability is of prime importance.
I dare to say the current development version works better and is more stable than your ancient Lazarus 1.97.
« Last Edit: June 07, 2023, 10:06:33 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #8 on: June 07, 2023, 10:21:05 am »
Hi, @JuhaManninen!

Quote
Oh boy, porting it requires some work. For example ExSys.pas has tons of IFDEFs for Windows / Linux, and the Linux part does not work. Such a unit should not be needed at all. FPC already provides cross-platform libraries which allows to write such code without any IFDEFs.
Somebody should properly port Vectors Library.

So, at least the problem has been solved! The Vectors Library is the cause of the problem. As far as I can tell, its author has not been active for decades. Probably FPC itself has containers classes which could replace the functions in that library, but  I surely do not have neither the time nor the inspiration to try refactoring this code now!

Quote
I dare to say the current development version works better and is more stable than your ancient Lazarus 1.97.

Actually I am using Lazarus 2.0.12, which is not so old! Anyway, upgrading would not solve the problem, because it is caused by an external library.

Thank you very much!

With warmest regards,

UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #9 on: June 07, 2023, 10:44:05 am »
Actually I am using Lazarus 2.0.12, which is not so old! Anyway, upgrading would not solve the problem, because it is caused by an external library.
The remaining question is why your Lazarus froze during compilation. For me it showed compiler errors correctly.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #10 on: June 07, 2023, 12:06:59 pm »
I cloned the libro project referred to in the first post. At first I tried to avoid installing the HistoryFiles package because I thought I could replace it in the end by mrumenu which comes with Lazarus. i downloaded the sources and copied them to a "3rd-party" folder of the project and added it to the unit path of the project. Then I edited the main.pas and created the THistoryFile component at runtime and deleted it from the lfm file. This way the package is only accessed at runtime, I do not have to rebuild the IDE, and there is no risk to crash the IDE.

Next step was the Vectors library. I copied the source directory into the 3rd-party folder again, and added it to the path.

Hoping that this would enough I tried to compile. There was one issue with the HTMLViewer referring to a "DocumentSource" which does not seem to exist any more. Looking at the THMLViewer source I found a property "Text" which sounded like a good replacement.

Next compilation attempt - it worked! I loaded a text file and a simple html file --> ok.

In the next step I removed the THistoryFile component at all and replaced it by TMruMenuManger in the mrumenu package which is included in the Lazarus distribution. This removes the risk of using an unmaintained external package...

I am aware that the HTMLViewer used in your project is superior to the TurboPower HTMLPanel available in Lazarus, but your html code is quite simple and therefore I tried to replace it by the TurboPower component. And it was working, too. This had the advantage of removing a dependence on an external component.

The final step would be to remove the Vectors library. The TIntegerVector looks like as if it could be replace by the TIntegerList, and the TTextStream and TStrCounter look doable as well. But then I noticed that they are woven deeper into your code than expected, and I gave this up. But I am still convinced that Vectors can be removed.

I am attaching the final version of your code. All (?) my changes are marked by "!! wp".

maurobio

  • Hero Member
  • *****
  • Posts: 623
  • Ecology is everything.
    • GitHub
Re: IDE freezing on opening project converted from Delphi under Linux
« Reply #11 on: June 07, 2023, 02:25:15 pm »
Hi, @wp!!!

Thanks a lot for your as always very helpful and much constructive insights!

I am surely in favour of using as much external interface libraries as possible, to avoid the risk of depending upon unmaintained code.

As of THistoryFiles, I have long wondered why LCL did not include a MRU component! But it seems that my relatively old version (2.0.12) of Lazarus does not include any such component, therefore I had to resort to an external package. Now, I see a good reason for updating my Lazarus installation! ;)

As of THTMLViewer, I have used that fine component since the first Delphi versions, almost three decades ago! I was delighted when I found out that it has been ported to Lazarus, and then I could keep using it. It  is, as you pointed out, much better than the HTML viewer component which comes with Lazarus. But if it can, in some cases, replace the external component, without compromising the functionality of the application, so I surely do not object. Just as an aside, I had not any issue with the DocumentSource property, either under Windows or Linux (I have another, much larger application, which also uses this component but compiles and runs fine either under both operating systems). Perhaps I am also using an older version of the package.

But the Vectors Library is a different case. In fact, this program only exists because of this library, since it provides much of the functionality which constitute the raison d'être of the program. Probably, there are container classes in modern Lazarus which can replace the function provided by the Vector Library, but I can't say. In my opinion, the ideal solution would be to adapt the Vector Library to work in Lazarus uder Linux (because these problems do not appear under Windows).

I will take a look at your code and, in due time, may include one or more of the modifications in a new release of the Libro application.

Again, thank you very much for your help!

With warmest regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 2.0.12 - FPC 3.2.0 on GNU/Linux Mint 19.1, Lubuntu 18.04, Windows XP SP3, Windows 7 Professional, Windows 10 Home

 

TinyPortal © 2005-2018