• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

FREE TCOMPONENTLIST

FREE TCOMPONENTLIST

When I try to free TComponentList I get this error :

ACCESS VIOLATION,

and every time (after free method) when I try to use TComponentList named ComponentList.

How to solve this problem ?

Thanks.
0
ghjlk
Asked:
ghjlk
  • 2
1 Solution
 
kretzschmarCommented:
you should show how you free and access your list
0
 
ghjlkAuthor Commented:
//first oncreate event
componentlist.create;

//then two methods of create components
componentlist.add &
componentlist.insert

//in componentlist I put Forms, ActiveX components and others.


//section new
while componentlist.count>0 do
TControl(componentlist[0]).Free;

componentlist.free;
componentlist.create;

Thanks.
0
 
ghjlkAuthor Commented:
Sorry :
componentlist:=TComponentlist.create;
0
 
CynnaCommented:
ghjlk,

Try creating componentlist like this:
 
  componentlist:=TComponentlist.Create(FALSE);

This will ensure that componentlist.free doesn't try to free components that you already freed before.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now