Database + Form OnActivate problem lazarus / 16-Databases ---------------------------------------------------------------------- ozoltan · 2016-03-17 12:04 I have encountered a very strange behaviour of a form. I usually use the OnCreate, OnActivate and OnClose events of a form. When accessing database, in a special circumstances - always reproduceable - the OnActivate event of the form is called again after exiting the form through its OnClose event. I am using the Lazarus built-in database handling routines for accessing a PostgreSQL database... One may find the test program as attachment. In the ZIP file there is a description of the bug... ---------------------------------------------------------------------- balazsszekely · 2016-03-17 12:19 @ozoltan First of all, we should rule out if this is not a debian related issue. I have somewhere an old debian(7.8 ), I will fire it up probably tomorrow. ---------------------------------------------------------------------- ozoltan · 2016-03-17 12:38 GetMem (Balázs?) Ok, I have found this problem on my older computer using Debian 7.5 After that I have installed Debian 8.3 to test on another computer. Me too I will search for an Ubuntu 14.04, I think I have an install disk somewhere... ---------------------------------------------------------------------- ozoltan · 2016-03-17 15:34 Only very-very quietly I am saying that under Lazarus 1.7 - downloaded from -> http://mirrors.iwi.me/lazarus/snapshots/ <- it seems that is working correctly. I dont have the bug anymore in the test version... Tomorrow I will start testing with the whole program.... But if this will solve my problem, then it seems to me that it is some very deeply hidden problem in Lazarus 1.6, that is corrected - maybe unwatedly - in the 1.7 version... I will share my results... ---------------------------------------------------------------------- balazsszekely · 2016-03-17 16:06 @ozoltan Ok, this is good news. I will also install Lazarus 1.6 to my Debian 7.5, let's see if I can reproduce the bug. ---------------------------------------------------------------------- ozoltan · 2016-03-17 17:35 @GetMem... That was a very good idea making a video... Tomorrow I will try to make a video about the bug and send it to U somehow... ---------------------------------------------------------------------- ozoltan · 2016-03-18 06:56 @GetMem !!! VERY IMPORTANT !!!    If U install Debian, then please use KDE surface, because I am using that one and the program is running on that surface at the client... Me also I have installed Kubuntu 14.04 to test... Thx! ---------------------------------------------------------------------- balazsszekely · 2016-03-18 10:27 @ozoltan I was able to reproduce the error both under ubuntu and debian(the desktop manager is irrelevant). The strange thing is a new blank application works fine, something in your application triggers the behaviour, but only with Laz 1.6. I would switch to trunk instead of you, but if you somehow need to stay with 1.6 there is a workaround: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TFizetAF = class(TForm)  //...  private    NeedToClose: Boolean;  end; //..rocedure TFizetAF.FormOnActivate(Sender: TObject);var   s0, s1: shortstring;begin  if NeedToClose then  begin    NeedToClose := False;    Exit;  end;  //...end;     procedure TFizetAF.BKilepesClick(Sender: TObject);begin  if UtilsF.YesNo('...') = mrYes then  begin    NeedToClose := True;    FizetAF.ModalResult:=mrOk;  end;end; ---------------------------------------------------------------------- ozoltan · 2016-03-18 11:50 @GetMem I am extremly happy that U could reproduce the bug The problem is that for the first I had this bug under Laz 1.4.4... Then Juha adviced me to switch to Laz 1.6 and there I had the bug too.. No need for Lazarus 1.6   I need a Lazarus that works well and most of all... Its reliable!!! It seems that Laz 1.7 (trunk) doesnt have this problem... ---------------------------------------------------------------------- JuhaManninen · 2016-03-19 08:57 Quote from: GetMem on March 18, 2016, 11:27:43 amThe strange thing is a new blank application works fine, something in your application triggers the behaviour, but only with Laz 1.6. Indeed strange. If you could reproduce it systematically with a test app, then we could find the revision in Lazarus trunk that fixed it and backport it to 1.6_fixes branch. For a ghost bug it makes no sense. Anyway, if the problematic app now works with trunk, just use it. ---------------------------------------------------------------------- balazsszekely · 2016-03-19 10:10 @Juha Ok. I will make a few more attempts to reproduce with a test application. ---------------------------------------------------------------------- ozoltan · 2016-03-19 20:48 Somehow this bug its related to database access. If I comment out the database access then no bug... But this bug can be reproduced with ZeosDb or the Lazarus built-in database routines. Also if U comment out the Yes/No message dialog in FizetAF.BKilepesClick routine, also no bug... So it seems to me that this bug comes out in a rather rare and special combination... But the problem that makes bugs on other places... Eg. sum or count some fields... I couldnt reproduce it with few lines test applications ---------------------------------------------------------------------- balazsszekely · 2016-03-21 06:35 @Juha, @Zoltán I successfully reproduced the issue with a test application(see attachment). The bug is only present under GTK2. All other widgetset are imune(Win32/64, QT win, Carbon). Step to reproduce:     1. Open Form2     2. Click  Button1     3. Click Yes After form close, form activate is called once again, which is wrong. Lazarus 1.6 FPC 3.0.0 Ubuntu 14.04 LTS