Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread wkitty42

On 02/09/2016 04:10 AM, Bo Berglund wrote:

On Mon, 8 Feb 2016 23:24:35 +0100, mic...@gmail.com wrote:


I am using Lazarus 1.6RC2 and FPC 3.0.0 on Raspbian Jessie.

reboot ist not needed on linux
use a console and kill command
Ctrl-Alt-F1 for console


Or use the terminal icon on the taskbar, right?
But then what? How do I use kill to shut down Lazarus?
I am used to Windows Task Manager where the running programs are
listed and one can stop it, but how do I get a corresponding list in
which to select Lazarus in Linux?


i generally use something like this

  ps aux | grep -Ei -e "[l]azarus"

the square braces around the first letter in the grep cause grep to find the 
real occurrence and not a second one which would be itself...


one can also use the system monitor or top or numerous other tools that show 
what programs and services are running... most all of those will show the pid...


i was also thinking that there might be a pid file for lazarus... they're 
generally found in /var/run but i don't see one in there... IF there were one, 
one could use a command similar to this...


  kill -TERM `cat /var/run/Lazarus.pid`

OR

  kill -TERM `pgrep Lazarus`


note that there is case sensitivity at play with the file name of the PID... and 
once again, lazarus apparently does not have a pid file...


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list* unless
   private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread Dmitry Boyarintsev
On Mon, Feb 8, 2016 at 6:22 PM, Mattias Gaertner 
wrote:

> Do you mean you added -dUseCThreads in
> Project/Project_Options/Custom_Options,
> but it is not appended to options passed to FPC?
>

Is it true to say that there are only 2 ways in IDE to set defines.
1) Project Options/Custom Options
2) Project Options/Additions and Overrides (+ Custom Option)

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread Bo Berglund
On Tue, 9 Feb 2016 00:22:21 +0100 (CET), Mattias Gaertner
 wrote:

>> I tried setting the conditional "UseCThreads" for my test project but
>> even though I can reach the place where this apparently is set:
>> Menu: Project/Project_Options/Custom_Options/Defines
>> it seems not to work!
>
>Do you mean you added -dUseCThreads in Project/Project_Options/Custom_Options,
>but it is not appended to options passed to FPC?

No I did not add the -d in front of the UseCThreads symbol, just the
symbol itself.

I used Menu: Project/Project_Options/Compiler_Options/Custom_Options
This was the only place I found the word Defines, which appears on a
button to the right. It is in subnode Compiler_Options, which did not
sound right to me anyway since I wanted the symbol to be global
including the Lazarus IDE code parser, but I did not find defines
anywhere else...

Then I clicked the button and an input dialog named Defines popped up.
It has a text input box named Define into which I typed UseCThreads
Then I clicked the Add button and this name appeared in the list
below, so I clicked OK and the input dialog disappeared and I was back
in the Custom_Options dialog with nothing showing in the list there.
If I cancel at this point everything works out except for the define
but on the second try I clicked OK and then Lazarus locked up.

> 
>> When I use this dialog to enter the symbol UseCThreads the effect is
>> invisible when I hit OK
>
>Did you enable the checkbox of the define?

I see a checkbox "Build modes" on top of the Custom_Options dialog, is
this the box you mean? I have not checked it.


>>, nothing gets added to the list of
>> defines/options and when I OK on the main options window anyway
>> Lazarus locks up completely!!!
>
>It works here on OS X/carbon. Maybe the bug only appears on your platform.

It should not be any different, Lazarus itself uses the same sources
on all plöatforms as far as I understand. I retrieved 1.6RC2 from svn
when I built Lazarus.

Different workaround solution:

If I open the project file and add this directly on the next line
following the top line "program MyTCPTest":
{$DEFINE UseCThreads}

then it actually does work.
But the Delphi way seems easier with a separate project option for the
defines...


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread Bo Berglund
On Mon, 8 Feb 2016 23:24:35 +0100, mic...@gmail.com wrote:

>> I am using Lazarus 1.6RC2 and FPC 3.0.0 on Raspbian Jessie.
>reboot ist not needed on linux
>use a console and kill command
>Ctrl-Alt-F1 for console

Or use the terminal icon on the taskbar, right?
But then what? How do I use kill to shut down Lazarus?
I am used to Windows Task Manager where the running programs are
listed and one can stop it, but how do I get a corresponding list in
which to select Lazarus in Linux?
'man kill' indicates that I need a  value but 'man pid' returns
nothing.

>Ctrl-Alt-F7 to go back to X
>
>UseCThreads is normaly added in the *.lpr file
>Project->Project Inspektor
> doubleclick lpr file

When I added
{$DEFINE UseCThreads}
as the first line following the program line it works.
:)


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread JuuS


On 02/09/2016 10:10 AM, Bo Berglund wrote:
> On Mon, 8 Feb 2016 23:24:35 +0100, mic...@gmail.com wrote:
> 
> I am used to Windows Task Manager where the running programs are
> listed and one can stop it, but how do I get a corresponding list in
> which to select Lazarus in Linux?

All linux flavors have this as well. In kUbuntu it is called system
monitor (underlying name is ksysguard).

> 'man kill' indicates that I need a  value but 'man pid' returns
> nothing.

use ps command (ps --help all) to get PID's.  ps aux is a good start,
but use grep to winnow it down.

Julius

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread Bo Berglund
On Tue, 9 Feb 2016 11:32:10 +0100, JuuS  wrote:

>> 'man kill' indicates that I need a  value but 'man pid' returns
>> nothing.
>
>use ps command (ps --help all) to get PID's.  ps aux is a good start,
>but use grep to winnow it down.

Tried this:
pi@rpi2-jessie2:~ $ ps -u pi |grep lazarus
 5091 ?00:00:00 startlazarus
 5094 ?00:00:10 lazarus

Seems to be two processes with lazarus in the name.
Which one (or both) do I kill?


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread Henry Vermaak
On Tue, Feb 09, 2016 at 10:10:05AM +0100, Bo Berglund wrote:
> 'man kill' indicates that I need a  value but 'man pid' returns
> nothing.

`killall` takes the name of the process, and tab completion works on
most systems I've tried.

Henry

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread patspiper

On 09/02/16 10:38, Bo Berglund wrote:

No I did not add the -d in front of the UseCThreads symbol, just the
symbol itself.

I used Menu: Project/Project_Options/Compiler_Options/Custom_Options
This was the only place I found the word Defines, which appears on a
button to the right. It is in subnode Compiler_Options, which did not
sound right to me anyway since I wanted the symbol to be global
including the Lazarus IDE code parser, but I did not find defines
anywhere else...
Manual way: Add -dUseCThreads in 
Project/Project_Options/Compiler_Options/Custom_Options


Then I clicked the button and an input dialog named Defines popped up.
It has a text input box named Define into which I typed UseCThreads
Then I clicked the Add button and this name appeared in the list
below, so I clicked OK and the input dialog disappeared and I was back
in the Custom_Options dialog with nothing showing in the list there.
If I cancel at this point everything works out except for the define
but on the second try I clicked OK and then Lazarus locked up.
If you use the defines button, make sure the checkbox next to 
UseCThreads is ticked. -dUseCThreads will show up automatically in 
Project/Project_Options/Compiler_Options/Custom_Options


Stephano

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Video Tutorial: Introducing Lazarus

2016-02-09 Thread Anthony Walter
I've published a new video in my tutorial series. This new video serves as
an introduction the Lazarus IDE for the uninitiated. Feel free to post this
link to other websites. I'm hoping it reaches people who haven't given the
idea of development with Lazarus its due consideration.

http://www.getlazarus.org/learn/tutorials/intro/
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Exclude components from localization by path or text

2016-02-09 Thread Denis Kozlov

I've implemented this feature and attached a patch:
http://bugs.freepascal.org/view.php?id=29627

In summary:
1) Added methods to remove entries from TPOFile by identifier and by 
original text.

2) Implemented storage of excluded identifiers and originals via TProject.
3) Updated translation routines to pass over project's excluded 
identifiers and originals when updating PO files.

4) Editing of excluded identifiers and originals in i18n project options.
5) Added option to "Force update PO files on next compile" in i18n 
project options (auto reset, non-persistent). To force update PO files 
after changing excluded identifiers and originals.


I hope this could be merged into either 1.4 or 1.6 as it's an extremely 
useful feature for i18n.


Denis

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread JuuS


On 02/09/2016 11:56 AM, Bo Berglund wrote:
> On Tue, 9 Feb 2016 11:32:10 +0100, JuuS  wrote:
> 
>>> 'man kill' indicates that I need a  value but 'man pid' returns
>>> nothing.
>>
>> use ps command (ps --help all) to get PID's.  ps aux is a good start,
>> but use grep to winnow it down.
> 
> Tried this:
> pi@rpi2-jessie2:~ $ ps -u pi |grep lazarus
>  5091 ?00:00:00 startlazarus
>  5094 ?00:00:10 lazarus
> 
> Seems to be two processes with lazarus in the name.
> Which one (or both) do I kill?

I would assume the higher PID is the child of the lower. You can also
specify --forest with the ps command and it gives ascii art tree showing
parent child relationships.

I'm no linux expert but I would kill child first then parent. But it may
be killing parent automatically kills child.?.

Then again you can use (at least in kUbuntu) the system monitor to kill
processes, right click on the entry on the processes tab.

> 
> 

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Exclude components from localization by path or text

2016-02-09 Thread Mattias Gaertner
>[...]
> I hope this could be merged into either 1.4 or 1.6 as it's an extremely 
> useful feature for i18n.

Sorry, only bug fixes can go to 1.6.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to set defines for a project? Lazarus crashes...

2016-02-09 Thread micsch
Am Tuesday 09 February 2016 10:10:05 schrieb Bo Berglund:
> On Mon, 8 Feb 2016 23:24:35 +0100, mic...@gmail.com wrote:
> >> I am using Lazarus 1.6RC2 and FPC 3.0.0 on Raspbian Jessie.
> >
> >reboot ist not needed on linux
> >use a console and kill command
> >Ctrl-Alt-F1 for console
>
> Or use the terminal icon on the taskbar, right?
> But then what? How do I use kill to shut down Lazarus?
> I am used to Windows Task Manager where the running programs are
> listed and one can stop it, but how do I get a corresponding list in
> which to select Lazarus in Linux?
> 'man kill' indicates that I need a  value but 'man pid' returns
> nothing.
>
> >Ctrl-Alt-F7 to go back to X
> >
> >UseCThreads is normaly added in the *.lpr file
> >Project->Project Inspektor
> > doubleclick lpr file
>
> When I added
> {$DEFINE UseCThreads}
> as the first line following the program line it works.
>
> :)
man top ;)



'top' command is your friend
then

k for kill
then the signal to kill
9 for termination ;)
15 for asking polite to close ;)

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Video Tutorial: Introducing Lazarus

2016-02-09 Thread Anthony Walter
Dmitry, I have a friend who is a television news talent reading my scripts.

My reading voice sounds like this:
http://cache.getlazarus.org/audio/sysrpl.m4a

My friend does a better job and it only takes him a few minutes to record
stuff. Plus he has a way better microphone.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Video Tutorial: Introducing Lazarus

2016-02-09 Thread Dmitry Boyarintsev
On Tue, Feb 9, 2016 at 3:35 AM, Anthony Walter  wrote:

> I've published a new video in my tutorial series.
>

Just curios, is it your voice on the video?

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Lazarus code editor width not smaller than 1060 px?

2016-02-09 Thread Bo Berglund
Lazarus 1.6RC2 & FPC 3.0.0 on Raspbian Jessie

When I try to change the horizontal width of the code editor window in
Lazarus I am able to increase it but not to reduce it.
I made a screenshot image so I could evaluate the width in pixels and
it seems like it refuses to reduce smaller than 1060 pixels or so.
I can grab the lower right corner handle but I cannot move it left;
up/down/right is OK though.
Likewise I can grab the right border handle and move it to the right
but not left.
If I increase the width and then try to reduce it I can do it down to
about 1060 pixels.
The same exact behaviour on the HDMI output channel (display :0) and
on the VNC connection (display :1)

What can be the reason for this behaviour?


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Video Tutorial: Introducing Lazarus

2016-02-09 Thread Dmitry Boyarintsev
On Tue, Feb 9, 2016 at 4:59 PM, Anthony Walter  wrote:

> I have a friend who is a television news talent reading my scripts.
>

Thanks for clarification!
The pro voice indeed makes it pro quality video.

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Lazarus application crash. Is PostMessage thread safe?

2016-02-09 Thread Giuliano Colla

Hi Lazarus guru's,

I have stumbled into a problem with a Lazarus application. At random 
times, from 5 minutes to several hours, it crashes suddenly, and silently.

The only way to get a clue has been to run it with gdb.

It turns out that the crash occurs because of a Segmentation Fault in 
QTextEngine, triggered by a PostMessage, but apparently the cause was an 
endless loop in a previous PostMessage, which was executed some 1723 
times. Attached the gdb stack trace (with 1722 identical items suppressed).


The scenario is a main thread using LCL, which is used, among other 
things not relevant here, to display information to the user, and 
another thread which communicates with a real-time process, and uses a 
PostMessage to wake up the main thread and make it show what required.


It appears that in some circumstances, the Application.ProcessMessages 
invoked in the main thread restarts the handling of the same message, 
thus creating and endless loop.


Is Application.ProcessMessages the vilain, or PostMessage or what?

Snippet of auxiliary thread code:



procedure TSendRec.DoDisplayError;
var
  Box: integer;
begin
   ErrList[ErrPut] := ErrMsg;
   inc(ErrPut);
   if ErrPut > High(ErrList) then ErrPut := 0;
   {$IFDEF USE_MESSAGES}
   PostMessage(Form1.Handle,LM_ERROR,Integer(ErrPut),0);
   {$ENDIF}
end;


Snippet of main thread code:


procedure TForm1.HandleError(var Msg: TLMessage);
var
.
begin
  inc(ErrorCnt);
  if ErrGet <> ErrPut then begin
ErrMsg := ErrList[ErrGet];
...
AnswerString := Format('UNIT %XH device %s ERROR
%XH',[ErrMsg.yunit,Localize(NamUn[ErrMsg.device]),ErrMsg.ytype]);
ShowError(Self,Answerstring,BoxError[Box],Box);
inc(ErrGet);
if ErrGet > High(ErrList) then ErrGet := 0;
end;
end;

procedure TForm1.ShowError(Sender: TObject; errorstring: string;
Berror: TBoxerror; ErrBox: Integer);
var
...
begin
. (code to fill up Panel4)
  Panel4.Show;
  Panel4.BringToFront;
  Application.ProcessMessages;
  ResetBtn.SetFocus;
end;


Thanks for any help

Giuliano


[Thread debugging using libthread_db enabled]
[New Thread 0x7fffe7a90700 (LWP 4310)]

Program received signal SIGSEGV, Segmentation fault.
0x003d6a7dc904 in QTextEngine::itemize() const () from /usr/lib64/libQtGui.so.4
#0  0x003d6a7dc904 in QTextEngine::itemize() const () from /usr/lib64/libQtGui.so.4
#1  0x003d6a6f1fc9 in QPainter::drawText(QPointF const&, QString const&, int, int) () from /usr/lib64/libQtGui.so.4
#2  0x77d297db in drawText (handle=0x1729710, x=10, y=33, s=0x7f805578) at /usr/include/QtGui/qpainter.h:916
#3  QPainter_drawText3 (handle=0x1729710, x=10, y=33, s=0x7f805578) at src/qpainter_c.cpp:865
#4  0x00751061 in DRAWTEXT (this=0x7fffe9ca2300, X=10, Y=33, S=0x7f805578) at qt/qtobjects.pas:2832
#5  0x006d190d in EXTTEXTOUT (this=0x748d5730, DC=140737115726592, X=10, Y=20, OPTIONS=0, RECT=0x0, STR=0x7fffe9ca7990 '1 Â'#150, COUNT=4, DX=0x0) at qt/qtwinapi.inc:2291
#6  0x00595551 in EXTUTF8OUT (this=0x748d5730, DC=140737115726592, X=10, Y=20, OPTIONS=0, RECT=0x0, STR=0x7fffe9ca7990 '1 Â'#150, COUNT=4, DX=0x0) at include/intfbaselcl.inc:214
#7  0x0057e41c in EXTUTF8OUT (DC=140737115726592, X=10, Y=20, OPTIONS=0, RECT=0x0, STR=0x7fffe9ca7990 '1 Â'#150, COUNT=4, DX=0x0) at include/lclintf.inc:147
#8  0x005c2890 in TEXTOUT (this=0x7fffea0eed80, X=10, Y=20, TEXT=0x7fffe9ca7990 '1 Â'#150) at include/canvas.inc:1360
#9  0x004e6fec in POSWRT (PIMAGE=33286, SYM=144 #144, BGCOL=0, FGCOL=65280, CANVAS=0x7fffea0eed80, POS=...) at USequen.pas:547
#10 0x004e7b8b in DISPLCOD (DEVICE=FEEDER1_DEV, DISPLCORR=false, B=...) at USequen.pas:761
#11 0x004fca93 in HANDLEMESSAGE (this=0x748d7790, MSG=...) at USequen.pas:5779
#12 0x004b47a1 in SYSTEM_TOBJECT_$__DISPATCH$formal ()
#13 0x004fc128 in ?? ()
#14 0x748d7790 in ?? ()
#15 0x0003 in ?? ()
#16 0x0465 in ?? ()
#17 0x7f8062e8 in ?? ()
#18 0x748d7790 in ?? ()
#19 0x0001 in ?? ()
#20 0x7fffe009ac60 in ?? ()
#21 0x7fffe009ac60 in ?? ()
#22 0x00d645d4 in ?? ()
#23 0x00e5ad10 in ?? ()
---
The following section repeated 1723 times:
#24 0x00602c6f in WNDPROC (this=0x748d7790, THEMESSAGE=...) at include/control.inc:2112
#25 0x005f3dc4 in WNDPROC (this=0x748d7790, MESSAGE=...) at include/wincontrol.inc:5341
#26 0x004d1afe in WNDPROC (this=0x748d7790, THEMESSAGE=...) at include/customform.inc:1443
#27 0x0072918d in DELIVERMESSAGE (this=0x7fffec014630, MSG=0, AISINPUTEVENT=false) at qt/qtwidgets.pas:5549
#28 0x00726cfc in SLOTLCLMESSAGE (this=0x7fffec014630, SENDER=0xe5ad10, EVENT=0x7fffe009ac60) at qt/qtwidgets.pas:4353
#29 0x007232c8 in EVENTFILTER (this=0x7fffec014630, SENDER=0xe5ad10, EVENT=0x7fffe009ac60) at qt/qtwidgets.pas:2678
#30 0x0072d364 in EVENTFILTER 

Re: [Lazarus] Exclude components from localization by path or text

2016-02-09 Thread Aradeonas
Thanks Denis.

Regards, Ara


-- 
http://www.fastmail.com - mmm... Fastmail...

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus application crash. Is PostMessage thread safe?

2016-02-09 Thread Denis Kozlov

On 09/02/2016 22:37, Giuliano Colla wrote:

PostMessage(Form1.Handle,LM_ERROR,Integer(ErrPut),0);


Is your LM_ERROR larger than LM_USER?

PostMessage is thread safe.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus application crash. Is PostMessage thread safe?

2016-02-09 Thread Denis Kozlov


You create a recursive scenario yourself by calling 
Application.ProcessMessages inside of ShowError inside of HandleError - 
which is the message handling procedure itself, which is triggered by 
Application.ProcessMessages.



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus application crash. Is PostMessage thread safe?

2016-02-09 Thread zeljko

On 02/09/2016 11:37 PM, Giuliano Colla wrote:

Hi Lazarus guru's,

I have stumbled into a problem with a Lazarus application. At random
times, from 5 minutes to several hours, it crashes suddenly, and silently.
The only way to get a clue has been to run it with gdb.

It turns out that the crash occurs because of a Segmentation Fault in
QTextEngine, triggered by a PostMessage, but apparently the cause was an
endless loop in a previous PostMessage, which was executed some 1723
times. Attached the gdb stack trace (with 1722 identical items suppressed).

The scenario is a main thread using LCL, which is used, among other
things not relevant here, to display information to the user, and
another thread which communicates with a real-time process, and uses a
PostMessage to wake up the main thread and make it show what required.

It appears that in some circumstances, the Application.ProcessMessages
invoked in the main thread restarts the handling of the same message,
thus creating and endless loop.

Is Application.ProcessMessages the vilain, or PostMessage or what?

Snippet of auxiliary thread code:



procedure TSendRec.DoDisplayError;
var
  Box: integer;
begin
   ErrList[ErrPut] := ErrMsg;
   inc(ErrPut);
   if ErrPut > High(ErrList) then ErrPut := 0;
   {$IFDEF USE_MESSAGES}
   PostMessage(Form1.Handle,LM_ERROR,Integer(ErrPut),0);
   {$ENDIF}
end;




Snippet of main thread code:


procedure TForm1.HandleError(var Msg: TLMessage);
var
.
begin
  inc(ErrorCnt);
  if ErrGet <> ErrPut then begin
ErrMsg := ErrList[ErrGet];
...
AnswerString := Format('UNIT %XH device %s ERROR
%XH',[ErrMsg.yunit,Localize(NamUn[ErrMsg.device]),ErrMsg.ytype]);
ShowError(Self,Answerstring,BoxError[Box],Box);
inc(ErrGet);
if ErrGet > High(ErrList) then ErrGet := 0;
end;
end;


1.Your ErrList access does not look thread safe.
2.You are casting postMessage param as integer, IMO it's wrong, 
shouldn't it be PtrInt or LPARAM ?

PostMessage(Form1.Handle,LM_ERROR, LPARAM(ErrPut),0);
3.Application.ProcessMessages probably recurse.

I'm using PostMessage() with QtLCL inside one app which heavily uses 
threads for gui controls updates and it works w/o problems, atm, one of
our users have that app running, uptime is cca 90 days (since last 
update). I don't use such lists, but creating record pointer and free it 
in main thread message queue



zeljko

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus