Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Closing an application with popup showing gives Abstract Error...

Posted on 2004-11-07
5
Medium Priority
?
223 Views
Last Modified: 2010-04-05
Well here is the problem...
 
A little while ago I started using that Actionbands update in most of my  menu's. (including my popup menu's; <= TPopupActionBarEx)
Now I've noticed that when the main popup menu is open and I close my application I get an Abstract Error.
I tried debugging my program but this error appears when the debugger is already gone through my code...(After the FormClose Event).

If I change my popup menu's back to the origional style (TPopupMenu) and I close my app with the popup open, it all closes smoothly without any errors...

It would be a shame to convert any of my popup menus back to old style, it just doesn't look the same...

Thanks a lot for your time!
0
Comment
Question by:Samball
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 12521739
try not to free anything yourself
i know that you have memory leaks in this way but it is for testing purposes only.

if you don't get the error you know that you free something that is later used
(or maybe freed) by the program.
this should give you a starting point

regards
alfred
0
 

Author Comment

by:Samball
ID: 12525531
Thanks Alfred,
this gives me a better inside, well...a little any way.

When I leave out all the Freeing of the objects I get the following error:

Exception EAccessViolation even before the Abstract Error

And this is comming from an Array of TTabsheets I created along the way, but if I destroy just these TTabsheets and the popup is open at closing time, I still get the Abstraction Error.

Could it be that I am doing something wrong with my creation/Freeing?
This is what I am doing:

private
      tabSheetArray: array of TTabSheet;
....

procedure TForm.newTab();
begin
....
     tabSheetArray[pageCount] := TTabSheet.Create(self);
     tabSheetArray[pageCount].Visible := false;
     tabSheetArray[pageCount].PageControl := myPageControl;
....
     tabSheetArray[pageCount].Visible := true;
....
end;

procedure TForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
     oI : integer;
begin
     for oI := 0 to pageCount - 1 do        
            tabSheet[oI].free;
end;


Any suggestions...?




0
 
LVL 3

Accepted Solution

by:
gandalf_the_white earned 480 total points
ID: 12530614
hmm
you create the tabsheets with the owner set to self:
   tabSheetArray[pageCount] := TTabSheet.Create(self);

that means when self (your form) is destroy it will destroy all
controls it is owner of.

so there are two ways to do it
1.create the tabsheets with nil and free them yourself
    tabSheetArray[pageCount] := TTabSheet.Create(nil);

2. create them with self and comment the free code in the formclose method as
   the form will do that for you


alfred
0
 

Author Comment

by:Samball
ID: 12533858
Well, I found the error...well kind off...
What I did in the onCloseQuery was write to an Ini file.
When I took this out and the popup was open it didnt give me any errors anymore, If I run the app without delphi (the .exe).
Else when running it in Delphi I still get the error...
For now, this is good enough for me...

Thanks a lot for your help...
You put me on the right path...
,

Samball...
0
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 12541618
np
i'm glad that i was able to help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question