Recent

Author Topic: Strange message handling!  (Read 3194 times)

BLL

  • Sr. Member
  • ****
  • Posts: 276
Strange message handling!
« on: November 25, 2015, 04:08:48 pm »
Hi
In my application, there is a form called setupForm, called from the main form by a button.
On the setupForm, there is another button called Reset. The ResetBtnClick function is as follows:

procedure TSetupForm.ResetBtnClick(Sender: TObject);
begin
 if MessageDlg('Warning', 'This will clear ALL current settings',
  mtConfirmation, [mbOk, mbCancel], 0) = mrCancel then exit;
 ShowMessage('Got here'); //temp for fault finding!
 PerDay.Value := 0;
 PerDay.Enabled := true;
 Cost.Value := 0;
 EPD.Checked[0] := true;
 Cunit.ItemIndex := 1;
 Tap.Checked[0] := false;
 Imax.Value := 16;
 StartDate.Date := Now;
 SetupForm.Repaint;
//command sent to PIC micro via ttyUSB1
 PortCom1.WriteData('*reset' + #13#10);
end;

On clicking the Reset button, in my ignorance, I would expect to see the MessageDlg appear, but it doesn't. The screen briefly flashes and that's all!
If you then click the Reset button a second time, the MessageDlg appears. However, choosing OK does not bring up the 'Got Here' message!
Clicking the Reset button for a third time shows the 'Got Here' message only!

Why is this happening and how can I make it work as logic dictates it should?

fpc 3.1.1, lazarus 1.5, Raspberry Pi with Raspbian

Thanks

Brian

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Strange message handling!
« Reply #1 on: November 25, 2015, 08:43:05 pm »
On the first glance, it sounds like a bug (but sorry, I'm not familiar with Raspberry).

Just to be sure that nothing in your program is interfering, have you also made a test with a minimal new project:
-2 forms,
-button1 in form1, showing form2,
-button1 in form2, calling your messagebox and getting the expecting result from it.

If this basic test doesn't work properly neither (i.e. messagebox shown every time, and sending back the correct result), I guess a new bug report should be introduced for the Raspberry platform.

BLL

  • Sr. Member
  • ****
  • Posts: 276
Re: Strange message handling!
« Reply #2 on: November 26, 2015, 12:00:40 pm »
Hi, Thanks for the suggestion. The test program works fine!

I tried commenting out all functionality on the form except the reset function, but no difference
Yet another example of flaky lazarus. I have had similar corruptions of forms/units before and the only solution is a new form and the annoyance of pasting all the controls across.
I came to lazarus from Borland CBuilder - what a difference! CBuilder was rock stable, whereas lazarus seems to have lots of problems and is anything but stable!

How I wish CBuilder existed on linux!

BLL

  • Sr. Member
  • ****
  • Posts: 276
Re: Strange message handling!
« Reply #3 on: November 26, 2015, 08:17:07 pm »
It gets worse!!
My little 2 form test program works fine.
So now I go back to my app and delete the setup form and its unit and remove them from the project.
Now I create a new form, name it SetupForm and call its unit setup.pas.
Fine, I can call it from the button on my main form.
I then add a bitbtn and put the messageDlg code in; run the program and it misbehaves just as before!
What on earth is going on? Why does it work in the test program and not in mine?
I just don't know how to proceed.

Brian

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Strange message handling!
« Reply #4 on: November 26, 2015, 08:51:12 pm »
It could be related to something else.

For instance, looking at the short extract of your source code, it seems you are using the TLazSerial package (or any other one, may be ?).

Try with and without it, if it is the case. Same thing, if you are using another package in your "real" project, and not in the test one.

« Last Edit: November 26, 2015, 09:30:07 pm by ChrisF »

BLL

  • Sr. Member
  • ****
  • Posts: 276
Re: Strange message handling!
« Reply #5 on: November 30, 2015, 09:53:00 am »
Thanks for the reply, but I don't see why the serial component should be upsetting event handling in a dialog box unrelated to it! Without the serial component, the program is useless.

I have fixed it only by going to the extreme of creating a form to look like a dialog and calling that, which works, but it's not very elegant!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11455
  • FPC developer.
Re: Strange message handling!
« Reply #6 on: November 30, 2015, 03:36:36 pm »

Yet another example of flaky lazarus.

If you compare it to embarcadero products, please test on Lazarus/Windows to exclude flaky Linux as the problem source (and Linux has problems bringing frames to the front as a rule)

To avoid that it might be easier to debug with a memo.

 

TinyPortal © 2005-2018