Recent

Author Topic: Application only updating when i move mouse  (Read 3650 times)

josh

  • Hero Member
  • *****
  • Posts: 808
Application only updating when i move mouse
« on: August 20, 2015, 09:34:06 am »
Hi
I have an application that retrieves data then updates a tmemo.
The code is working fine, however the TMemo is only visually being updated if I move or click the mouse.
I cannot use application.processmessages as this causes problems and is not really thread safe.

Any ideas, under windows I use a procedure that processes message; which works fine. But this will not work under OSX.

Any Ideas.

Josh
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

howardpc

  • Hero Member
  • *****
  • Posts: 3646
Re: Application only updating when i move mouse
« Reply #1 on: August 20, 2015, 09:43:02 am »
I cannot use application.processmessages as this causes problems and is not really thread safe.

What problems arise from the ProcessMessages call?
In what way is it not thread safe?

Have you tried calling yourMemoName.Invalidate after you change the Lines property (though I can't think why inserting this call manually should be needed)?
Perhaps you need to share the code you use to update the memo contents.
« Last Edit: August 20, 2015, 09:45:12 am by howardpc »

josh

  • Hero Member
  • *****
  • Posts: 808
Re: Application only updating when i move mouse
« Reply #2 on: August 20, 2015, 09:55:40 am »
Hi

Code using to update controls
Code: [Select]
memo1.lines.add(s);
memo1.update;

If I add processmessage as the data being generated is in a callback routine, now and again it will crash out.
In Windows I would use a routine like this which would work perfectly.
Code: [Select]
procedure WaitForallmessages;
var
  Msg: TMsg;
begin
  if not doing_messages then
  begin
    while ((PeekMessage(Msg, 0, 0, 0, PM_REMOVE))) do
    begin
      doing_messages:=true;
      if Msg.message = WM_QUIT then
      begin
        PostQuitMessage(Msg.wParam);
        Break;
      end;
      TranslateMessage(Msg);
      DispatchMessage(Msg);
    end;
    doing_messages:=False;
  end;
end;           

Doing_messages is a public variable defined
doing_messages:boolean=false;
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

howardpc

  • Hero Member
  • *****
  • Posts: 3646
Re: Application only updating when i move mouse
« Reply #3 on: August 20, 2015, 10:41:30 am »
Code snippets are not much help in debugging the work of others. Compilable code demonstrating the fault is needed.

josh

  • Hero Member
  • *****
  • Posts: 808
Re: Application only updating when i move mouse
« Reply #4 on: August 20, 2015, 10:54:07 am »
Hi,

Unfortunately that is not easy, as it requires specific hardware connected.

I will try to create an application that simulate the data arriving so that to demonstrate the problem.

Josh
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

Graeme

  • Hero Member
  • *****
  • Posts: 1431
    • Graeme on the web
Re: Application only updating when i move mouse
« Reply #5 on: August 20, 2015, 07:03:35 pm »
Code: [Select]
memo1.lines.add(s);
memo1.update;

I haven't tried your code personally, but maybe change the above to

Code: [Select]
memo1.BeginUpdate;
memo1.Lines.add(s);
memo1.EndUpdate;

Something like that.... I don't know LCL by heart, but if the above is wrong, try memo1.lines.beginupdate (and .endupdate) instead
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

ZXDunny

  • New member
  • *
  • Posts: 7
Re: Application only updating when i move mouse
« Reply #6 on: March 31, 2016, 11:21:56 am »
Sorry for the thread necro, but I also got this issue in OSX 10.11, until I selected the option in project options to automatically build a bundle for my application.

Prior to that, I only got updates to the UI when I moved the mouse or clicked/dragged - looked to be something to do with Lazarus running the app as a terminal application.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 639
Re: Application only updating when i move mouse
« Reply #7 on: March 31, 2016, 11:42:44 am »
Do you update the GUI from a different thread?

 

TinyPortal © 2005-2018