Autor Beitrag
Bob Murphy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 16.04.09 02:27 
Moin,
ich stehe wieder einmal vor einen kleinen Problem.
Gibt es eine Möglichkeit zu überprüfen ob eine TStringList schon freigegeben ist?
Hatte an sowas ähnliches gedacht^^
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
if StringList = free then
begin
  tu dies und das.....
end
else
begin
  StringList.Free;
end;


Hoffe jemand hat eine Idee:)

LG Bob
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 16.04.09 05:04 
Vielleicht hilft dir das hier weiter:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Assigned(DeineStringList) then
  //ist noch nicht freigegeben
else
  //ist freigegeben


Nächtliche Grüße,
Andy
Bob Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 16.04.09 06:12 
Ja sauber:) klappt wunderbar:)

BIG BIG THX

LG Bob
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 16.04.09 07:34 
Verwende zum Freigeben bitte FreeAndNil, da sonst die Wirksamkeit von Assigned nicht gewährleistet ist.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Bob Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 91

XP, Ubuntu
Delphi 7 SE, Delphi 2007
BeitragVerfasst: Do 16.04.09 19:47 
KK:) Danke für den Tipp:)
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 16.04.09 19:52 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
Verwende zum Freigeben bitte FreeAndNil, da sonst die Wirksamkeit von Assigned nicht gewährleistet ist.

Die Alternative möchte ich auch noch erwähnen:

ausblenden Delphi-Quelltext
1:
2:
StringList.Free;
StringList := nil;

Nichts weiter macht FreeAndNil, man kann es aber auch ausgekoppelt schreiben.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Do 16.04.09 20:05 
Wenn dann aber ne Exception im Destruktor auftritt ist das Objekt freigegeben aber wird nicht nil gesetzt.
FreeAndNil machts anders:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure FreeAndNil(var Obj);
var
  Temp: TObject;
begin
  Temp := TObject(Obj);
  Pointer(Obj) := nil;
  Temp.Free;
end;

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.