 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Frederico Pissarra Guest
|
Posted: Sat Oct 21, 2006 12:59 am Post subject: Is this correct? (TADOConnection) |
|
|
Hello!!!
Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:
-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;
-------------%<------------cut here -------------%<------------------------
Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.
Is this correct?
[]s
Fred |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Oct 21, 2006 2:24 am Post subject: Re: Is this correct? (TADOConnection) |
|
|
Not sure what you are asking, the code is from the unit ADODB. Are you
wondering if your connection/object is free at this point?
Frederico Pissarra wrote:
| Quote: | Hello!!!
Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:
-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;
-------------%<------------cut here -------------%<------------------------
Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.
Is this correct?
[]s
Fred |
|
|
| Back to top |
|
 |
Bill Dekleris Guest
|
Posted: Sat Oct 21, 2006 8:11 am Post subject: Re: Is this correct? (TADOConnection) |
|
|
Frederico,
if you take a look at FConnectionObject's declaration, you'l see that it
is a "pointer" to an interface (ADOInt._Connection) that descends from
IInterface, and as such it is reference counted. So, when you assign nil
to this pointer, the underlying object is freed. So, yes, the command is
correct.
Bill Dekleris
Quasar Software.
--
-----------------------------------------------------------------------------------------
http://www.infosnap.eu
Home page of InfoSnap - the powerful, all-purpose information and
knowledge-base manager.
-----------------------------------------------------------------------------------------
Frederico Pissarra wrote:
| Quote: | Hello!!!
Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here), you
can see the following code:
-------------%<------------cut here -------------%<------------------------
destructor TADOConnection.Destroy;
...
FConnectionObject := nil;
...
end;
-------------%<------------cut here -------------%<------------------------
Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.
Is this correct?
[]s
Fred
|
|
|
| Back to top |
|
 |
Frederico Pissarra Guest
|
Posted: Mon Oct 23, 2006 6:40 pm Post subject: Re: Is this correct? (TADOConnection) |
|
|
<danielk1 (AT) wi (DOT) rr.com> escreveu na mensagem
news:1161379473.609229.42860 (AT) e3g2000cwe (DOT) googlegroups.com...
| Quote: | Not sure what you are asking, the code is from the unit ADODB. Are you
wondering if your connection/object is free at this point?
|
Precisely.... Notice that connection object is created in the constructor in
CreateADOObject() function - wich calls CoCreateInstance with the proper
CLSID.
CoCreateInstance will call AddRef() IUnknown's member, but at the destructor
FConnectionObject is simply set to nil without calling Release()!
This means any connection object will remain in memory until the processes
dies... or am I wrong?
[]s
Fred
| Quote: | Frederico Pissarra wrote:
Hello!!!
Taking a look at ADODB unit in $(DELPHI)\Source\VCL (I'm using D7 here),
you
can see the following code:
-------------%<------------cut
here -------------%<------------------------
destructor TADOConnection.Destroy;
begin
Destroying;
Close;
ClearRefs;
FreeAndNil(FCommands);
if FConnEventsID > 0 then
OleCheck(ConnectionPoint.UnAdvise(FConnEventsID));
FConnEventsID := 0;
FConnectionObject := nil;
inherited Destroy;
end;
-------------%<------------cut
here -------------%<------------------------
Notice that FConnectionObject is not released (calling IUnknown.Release),
but the reference simply will point to nil.
Is this correct?
[]s
Fred |
|
|
| Back to top |
|
 |
Frederico Pissarra Guest
|
Posted: Mon Oct 23, 2006 6:41 pm Post subject: Re: Is this correct? (TADOConnection) |
|
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|