Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TSringList and OwnsObjects



Permlink Replies: 5 - Last Post: Oct 20, 2015 8:56 AM Last Post By: Remy Lebeau (Te...
ferenc nemeth

Posts: 4
Registered: 1/11/07
TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 2:39 AM
Hi

i would like to ask what is the default value of OwnsObjects in a TStringList object?
The next is Sorted ?

best regards feri

Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 2:48 AM   in response to: ferenc nemeth in response to: ferenc nemeth
i would like to ask what is the default value of OwnsObjects in a TStringList object?

False.

The next is Sorted ?

Sorted by default is False.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
ferenc nemeth

Posts: 4
Registered: 1/11/07
Re: TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 3:38 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
i would like to ask what is the default value of OwnsObjects in a TStringList object?

False.

The next is Sorted ?

Sorted by default is False.

--
With best regards,
Dmitry Arefiev / FireDAC Architect

thank you very much.
Can you tell me where is it set to default false?
because as I see in the source code I cannot find.

best regards
Robert Triest

Posts: 687
Registered: 3/24/05
Re: TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 4:07 AM   in response to: ferenc nemeth in response to: ferenc nemeth
TStringlist has a overload function Create where you can pass True or False in the parameter.
constructor TStringList.Create(OwnsObjects: Boolean);


As default a Boolean is set on False.
ferenc nemeth

Posts: 4
Registered: 1/11/07
Re: TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 4:19 AM   in response to: Robert Triest in response to: Robert Triest
Robert Triest wrote:
TStringlist has a overload function Create where you can pass True or False in the parameter.
constructor TStringList.Create(OwnsObjects: Boolean);


As default a Boolean is set on False.

Ok,
thank you very much !

feri
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TSringList and OwnsObjects
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 8:56 AM   in response to: ferenc nemeth in response to: ferenc nemeth
ferenc wrote:

Can you tell me where is it set to default false?
because as I see in the source code I cannot find.

TStringList has two constructors:

constructor Create; overload;
constructor Create(OwnsObjects: Boolean); overload;


If you call the second constructor, the OwnsObjects property is set to whatever
value you specify. However, if you call the first constructor (the usual
case), the OwnsObjects property is set to False by virtue of the fact that
TObject-derived classes are zero-initialized by the RTL before their constructors
are called, so the FOwnsObject data member is initially False and not overwritten.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02