Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
RTL
Delphi
Arithmetic
ConvUtils
Date - Time
DateUtils
File Management
Format + Float
Input/Output
Math Unit
Memory, Pointer, Address
Null-terminated strings
Other Classes
Other RTL
Pascal Strings
Regular Expressions
RTL Exceptions
Text Files
Thread support
Typed/Untyped Files
WinAPI
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/RTL/Delphi/Other RTL
[ Add a report in this area ]
Report #:
104609
Status:
Reported
Stringlist assignment to itselft clears content
Project:
Delphi
Build #:
XE, XE2
Version:
16.4
Submitted By:
Christian Holzner
Report Type:
Minor failure / Design problem
Date Reported:
4/4/2012 1:24:49 AM
Severity:
Infrequently encountered problem
Last Updated:
4/4/2012 11:26:31 PM
Platform:
All versions
Internal Tracking #:
Resolution:
None
Resolved in Build:
:
None
Duplicate of:
None
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
None
Description
An assignment of a TStringlist to itself clears its contents. Same behavior with a TList.
[System.Classes.pas]
------------
...
procedure TStrings.Assign(Source: TPersistent);
begin
if Source is TStrings then
begin
BeginUpdate;
try
Clear;
...
------------
Steps to Reproduce:
Execute the following code and see that after the "SL.Assign(SL2)" the stringlist(s) are empty.
------------
var
SL: TStringList;
SL2: TStringList;
begin
SL := TStringList.Create;
try
SL2 := SL;
SL2.Add('Foo');
ShowMessage(Format('SL.Count: %d; SL2.Count: %d', [SL.Count, SL2.Count]));
SL.Assign(SL2); // Clears the stringlist. "SL.Text := SL2.Text;" would work
ShowMessage(Format('SL.Count: %d; SL2.Count: %d', [SL.Count, SL2.Count]));
finally
SL.Free;
end;
------------
Workarounds
Assign to a copy of the stringlist.
Attachment
None
Comments
None
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us