🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2638

Re: Creating new TForm causes 'Out of Resources' error on WinXP

#2638
From: Remy Lebeau (TeamB)
Date: Fri, 19 Jan 2007 19:00
48 lines
2861 bytes
"Dan Mayo" <dmayo@dickey-john.com> wrote in message
news:45b0d69a$1@newsgroups.borland.com...

> "Note: When working with form objects, do not explicitly call the
Free
> or Destroy method to free them. Instead, use the Release method,
which
> waits until all event handlers have finished executing."

Do not call Free() or Destroy() ('delete' in C++) while inside one of
the TForm's own event handlers.  That is the only place where you need
to use Release() if the form wants to free itself.  Otherwise, Free()
and Destroy() ('delete') work fine.

> Does this mean I should call "theDialog->Release();" rather than
> "delete theDialog;"?

There is nothing wrong with doing that in the code you showed.  Using
'delete' is the proper thing to do in that situation.

> Reading the "Release()" function call help the note appears
> contradictory to the TForm() section:
>
> "Note: Release returns immediately to the caller. It does not wait
> for the form to be freed before returning."

That is correct.  Release() posts a CM_RELEASE message to the message
queue.  The form is freed when the message is processed later on.
That allows any active and pending event handlers to finish running
before the form is freed.

> So does Release() wait for everything to be done first before
> returning to the next line in code?

No.

> Do I need to call both Release() and then delete?

No.  That will crash your code as the TForm will be freed twice.

> Is there something I should do to make sure that Release() has
> finished prior to calling delete?

Stop using Release() in this situation.  It does not apply at all.


Gambit
Technical Details
Message-ID: <45b11553$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45afcda9$1@newsgroups.borland.com> <45afd2ea$1@newsgroups.borland.com> <45afd751$1@newsgroups.borland.com> <45afe953$1@newsgroups.borland.com> <45aff139$1@newsgroups.borland.com> <rgh1r2ln049empurv72i8uith6amj1hl4c@4ax.com> <45b0d38c@newsgroups.borland.com> <45b0d69a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,81568e00a202778e
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45afcda9$1@newsgroups.borland.com> <45afd2ea$1@newsgroups.borland.com> <45afd751$1@newsgroups.borland.com> <45afe953$1@newsgroups.borland.com> <45aff139$1@newsgroups.borland.com> <rgh1r2ln049empurv72i8uith6amj1hl4c@4ax.com> <45b0d38c@newsgroups.borland.com> <45b0d69a$1@newsgroups.borland.com>
Subject: Re: Creating new TForm causes 'Out of Resources' error on WinXP
Date: Fri, 19 Jan 2007 11:00:50 -0800
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <45b11553$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1169233235 75.83.34.171 (19 Jan 2007 11:00:35 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail