🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.nativeapi.win32
5 messages
5 total messages Started by Jan Doggen Wed, 02 Jul 2008 18:11
App does not stop on close of main form
#74
Author: Jan Doggen
Date: Wed, 02 Jul 2008 18:11
22 lines
1838 bytes
Hello

I inherited a quite complex app that does not shut down if I close the main 
form. Symptoms:
- The form disappears but the app keeps running (standalone or in the IDE).
- It does not exit from the Application.Run call in the project source
- It does not enter any of the FormDestroy events of the forms that were 
created (either autocreated in the project source, or dynamically in the 
OnCreate of the main form).
- If I pause execution and step through the CPU window I see it looping in 
TApplication.Run, calling Tapplication.HandleMessage in each loop. It is the 
code from 0046ADAD through 0046ADEC
in picture http://cjoint.com/?hcq5oQHfDt (available there until July 23, 
2008)

What else can I investigate to find the reason?

Thanks in advance for all tips
Jan
========================================================================================
http://www.jandoggen.org                      http://www.beautyofpeople.com 
http://www.puddingclub.nl 
Re: App does not stop on close of main form
#76
Author: Remy Lebeau (TeamB)
Date: Wed, 02 Jul 2008 20:00
50 lines
3156 bytes
"Jan Doggen" <JanDoggenREMOVETHISSPAMBLOCKER@planet.nl> wrote in message 
news:486bc4e3$1@newsgroups.borland.com...

> I inherited a quite complex app that does not shut down
> if I close the main form.

Then the code is not cleanup up after itself properly, leaving handles open, 
worker threads running, etc.

> - The form disappears but the app keeps running (standalone or in the 
> IDE).

A process does not fully termiante until all of its open handles have been 
closed.

> - It does not exit from the Application.Run call in the project source

The only ways that can happen is if either the WM_QUIT message is not being 
issued to begin with, or it is being intercepted and discarded before Run() 
can see it.

In the former case, closing the MainForm calls Application.Terminate(), 
which issues a WM_QUIT message only if no registered termination handlers 
prevent it.  A termination handler is registered using 
SysUtils.AddTerminateProc().  If any hander returns False, Terminate() does 
not post the WM_QUIT message.  If this were happening, your MainForm would 
not disappear, though, since it does not actually close when calling 
Application.Terminate(), but instead waits for the process shutdown to tear 
down its window later on instead.

In the latter case, a secondary message queue, such as inside a modal 
dialog, could be receiving the WM_QUIT and not re-posting it.  If that were 
happening, though, then I would still not expect the MainForm to disappear, 
either, since nothing is actually closing it.

> - It does not enter any of the FormDestroy events of the forms that were 
> created (either autocreated in the project source, or dynamically in the 
> OnCreate of the main form).

That won't happen until after Application.Run() exits and the TApplication 
object is destroyed during process shutdown.

> - If I pause execution and step through the CPU window I see it looping in 
> TApplication.Run, calling Tapplication.HandleMessage in each loop.

Then Run() is definatelly not receiving the WM_QUIT message correctly.


Gambit 
Re: App does not stop on close of main form
#79
Author: AlexB
Date: Thu, 03 Jul 2008 04:32
19 lines
1190 bytes
Jan Doggen wrote:

> I inherited a quite complex app that does not shut down if I close
> the main form. Symptoms:  - The form disappears but the app keeps
> running (standalone or in the IDE).

Often it happens when you wait for finishing of TThread objects:

Thread.Terminate;
Thread.WaitFor; // infinite loop

or

while SomeListOfThreads.Count>0 do
 Application.ProcessMessages;

Such code can be a part of destructor of some of component on form.
-- 
Alex
Re: App does not stop on close of main form
#105
Author: Jan Doggen
Date: Sun, 06 Jul 2008 14:27
37 lines
2456 bytes
The problem is solved

For some strange reason the Visible property of the main form was set TRUE
at design time, that forms OnShow would then be executed right after its
Create and before any other auto-created forms were created.
This was messing things up pretty badly.
By setting Visible to FALSE, the main forms' OnShow did not trigger until
after the creation of all auto-created forms

Jan

"Jan Doggen" <JanDoggenREMOVETHISSPAMBLOCKER@planet.nl> schreef in bericht 
news:486bc4e3$1@newsgroups.borland.com...
> Hello
>
> I inherited a quite complex app that does not shut down if I close the 
> main form. Symptoms:
> - The form disappears but the app keeps running (standalone or in the 
> IDE).
> - It does not exit from the Application.Run call in the project source
> - It does not enter any of the FormDestroy events of the forms that were 
> created (either autocreated in the project source, or dynamically in the 
> OnCreate of the main form).
> - If I pause execution and step through the CPU window I see it looping in 
> TApplication.Run, calling Tapplication.HandleMessage in each loop. It is 
> the code from 0046ADAD through 0046ADEC
> in picture http://cjoint.com/?hcq5oQHfDt (available there until July 23, 
> 2008)
>
> What else can I investigate to find the reason?
>
> Thanks in advance for all tips
> Jan
> ========================================================================================
> http://www.jandoggen.org 
> http://www.beautyofpeople.com http://www.puddingclub.nl
> 
Re: App does not stop on close of main form
#165
Author: David M
Date: Tue, 08 Jul 2008 06:07
65 lines
3798 bytes
> For some strange reason the Visible property of the main form was set TRUE
> at design time

This is normal, I think.

> that forms OnShow would then be executed right after its
> Create and before any other auto-created forms were created.
> This was messing things up pretty badly.
> By setting Visible to FALSE, the main forms' OnShow did not trigger until
> after the creation of all auto-created forms

I've had bugs affected by that sort of thing too, but I'd be wary of relying 
on this kind of fix - it sounds like a timing issue to me and alsmost 
anything could bring it back.  Wouldn't it be better to let the forms 
initialize, generate your data later, adn then refresh the forms with the 
new data?  (Speaking very generally, but I'm assuming this is a result of 
OnShow causing something to happen - instead, perhaps it should just flag it 
needs to happen, and it can actually happen at some other time.)

Cheers,

David


"Jan Doggen" <JanDoggenREMOVETHISSPAMBLOCKER@planet.nl> wrote in message 
news:4870d637@newsgroups.borland.com...
> The problem is solved
>
> For some strange reason the Visible property of the main form was set TRUE
> at design time, that forms OnShow would then be executed right after its
> Create and before any other auto-created forms were created.
> This was messing things up pretty badly.
> By setting Visible to FALSE, the main forms' OnShow did not trigger until
> after the creation of all auto-created forms
>
> Jan
>
> "Jan Doggen" <JanDoggenREMOVETHISSPAMBLOCKER@planet.nl> schreef in bericht 
> news:486bc4e3$1@newsgroups.borland.com...
>> Hello
>>
>> I inherited a quite complex app that does not shut down if I close the 
>> main form. Symptoms:
>> - The form disappears but the app keeps running (standalone or in the 
>> IDE).
>> - It does not exit from the Application.Run call in the project source
>> - It does not enter any of the FormDestroy events of the forms that were 
>> created (either autocreated in the project source, or dynamically in the 
>> OnCreate of the main form).
>> - If I pause execution and step through the CPU window I see it looping 
>> in TApplication.Run, calling Tapplication.HandleMessage in each loop. It 
>> is the code from 0046ADAD through 0046ADEC
>> in picture http://cjoint.com/?hcq5oQHfDt (available there until July 23, 
>> 2008)
>>
>> What else can I investigate to find the reason?
>>
>> Thanks in advance for all tips
>> Jan
>> ========================================================================================
>> http://www.jandoggen.org http://www.beautyofpeople.com 
>> http://www.puddingclub.nl
>>
>
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads