Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access violation at address .... in module 'Project1'.Read of address 1

Status
Not open for further replies.

MrEARTHSHAcKER

Programmer
Jan 26, 2012
20
0
0
Hi,

I have created the application which consists of several windows.
Except first window, all others are dynamically created.
They are created from windows before them and deleted after it's own closing ( they're deleted by themselves by button click ).

There is a problem.
When I wish to delete window, I get this error message : "Access violation at address 0A1826C8 in module 'Project1'.Read of address DD57D84A".

And it doesn't appear always, which is confusing. And it doesn't affect to the application, just displays the error.

Example of creating and deleting the window:

(withing 1st window)
MyTab= new TMyTab(Application);
MyTab->Show();

(withing window that'll be deleted - MyTab)

delete MyTab;


Thanks a lot, I need this because I don't want my game to be insane memory allocator.
 
Hmmmm. Do I understand you correctly that the window is trying to delete itself? I've been taught that the calling form should do the deleting. For example:
Code:
 // Delete old log files
    TLogClearForm *CLF = new TLogClearForm(Application);
    try
    {
        CLF->Show();
    }
    __finally
    {
        delete CLF;
    }



James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Can you explain me how I should call and delete window from single form?

Thanks.
 
For example if I use this method:

Code:
TForm1 *Cosmos = new TForm1(this);
 Cosmos->ShowModal();
 delete Cosmos;

How is Cosmos going to dynamically call another form while it closes/hides itself? The same way?
If so, when will Cosmos be deleted? After last form closes?

I have one main form in game, and 5 other forms which are supposed to be called over previous one MainTab->FirstTab->SecondTab->ThirdTab->FourthTab->FifthTab->MainTab

Well how would it be done? All from Main form?

Thanks again.
 
I made several experiments and I realized how does this work.

I do this
Code:
TForm1 *Cosmos = new TForm1(this);
 Cosmos->ShowModal();
 delete Cosmos;

And as long as the last form that has been called by Cosmos doesn't close, Cosmos won't be deleted (that was confusing me).

Practically I have the solution for my game, but what if I wished to destroy a form after it dynamically creates a new one and opens it?
I guess it is not possible since if I destroyed Cosmos, who'll delete the form it created.

Please if you find my conclusion wrong, point me to the spot I am wrong at.
Thanks!
 
I guess it is not possible since if I destroyed Cosmos, who'll delete the form it created.
Correct. One option, though, is to have the compiler create the form for you and have it destroy the forms. There are pluses and minuses to either option.


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
All right!

What about creating WindowsMediaPlayer withing dynamically created form?

I get the same error like above.

I tried several solutions like:
1.OnDestroy of form -> delete WindowsMediaPlayer1;;
2.OnClose -> like previous option;
3.Do nothing, just play it;
4.OnClose -> WindowsMediaPlayer->controls->stop();

And it seems like none of these do anything since I always get the same error, sooner or later.

And to make it more confusing, the MediaPlayer1 which is playing on first form ( pre-created ) isn't making problems.

I don't understand what to do, and I'm sure it's error because of MediaPlayer in dynamically created form because error doesn't appear unless I play it.

Thanks!
 
And one more problem.

Not always, but sometimes automatically when I close dynamically created form, it gives me the following error:


Code:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 6947CCC6 in
module 'wmp.dll'. Read of adress 00000009. Process stopped. Use Step or Run to continue.

I guess this is dll for WindowsMediaPlayer, but what can lead to the error I get?

I made isolated project with this situation and I get same errors.

 
( I hope I won't be accused for spamming :D )

When I get first of those 2 errors, BCB points me to Forms.hpp and to the line:

Code:
	/* TCustomForm.Destroy */ inline __fastcall virtual ~TForm(void) { }

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top