Recent

Author Topic: (SOLVED) unhandled EAccessViolation-Error after program closes!?  (Read 5920 times)

Nukualofa

  • New member
  • *
  • Posts: 7
(SOLVED) unhandled EAccessViolation-Error after program closes!?
« on: December 03, 2015, 06:41:50 pm »
Hey,

I have a very strange problem:

I'm writing a multiplayer-online-game adaption of Settlers of Catan, and what already works is that one person can open a server and others can connect to the server. When the server-guy clicks on the Start-Game-Button, everyone gets the main game board window (in the attachment I replaced it with a simple form that's doing nothing, because the error is occuring then as well). When you close that form and all the other forms, an error occurs. If you don't click the Start-Game-Button and close all the forms, the error doesn't occur. To make matters even more strange, the error seems to occur only if there is just one player.

The error message looks like this:

An unhandled exception occured at $0040E575 :
EAccessViolation : Access violation
 $0040E575
 $0040ACC2
 $00469F01 FREENODE, line 1496 of avglvltree.pas
 $00469F01 FREENODE, line 1496 of avglvltree.pas
 $00469ED6 TAVGLVLTREE__FREEANDCLEAR, line 1505 of avglvltree.pas
 $004BCD35 TRESOURCECACHE__CLEAR, line 367 of lclrescache.pas
 $004BCD70 TRESOURCECACHE__DESTROY, line 373 of lclrescache.pas
 $0040ACC2
 $0044D96E CALLINTERFACEFINALIZATIONHANDLERS, line 843 of lclproc.pas
 $00414BE0 FREEWIDGETSET, line 2080 of forms.pp
 $00413AC8 INTERFACES_finalize, line 40 of interfaces.pp
 $0040D138

To reproduce the error, run the program and click the button "Spiel eröffnen", change the value of the spinedit "Spielerzahl" to 1, click the button "Spiel eröffnen" and then the button "Spiel starten". Then close all the forms.

I try to solve this problem for a couple of days already, so any idea is welcome!

Thanks for your time!
« Last Edit: December 03, 2015, 08:49:27 pm by Nukualofa »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: unhandled EAccessViolation-Error after program closes!?
« Reply #1 on: December 03, 2015, 07:42:49 pm »
The error pops up in avltree, but is nothing to do with that code.
Look at your NetworkThread unit, the startGame method.

Player is a dynamic array, so indexed from zero. But your enumerator, i, starts at 1.
So your player[ i]:=TSpieler.Create... should be
Code: Pascal  [Select][+][-]
  1. player[i-1] :=TSpieler.Create...
  2.  
and the reihenfolge:=player[1].getName should presumably be
Code: Pascal  [Select][+][-]
  1. reihenfolge:=player[0].getName;
  2.  

There may be other errors, but those changes should remove at least one access violation.

Nukualofa

  • New member
  • *
  • Posts: 7
Re: unhandled EAccessViolation-Error after program closes!?
« Reply #2 on: December 03, 2015, 08:49:08 pm »
That's it! Thank you so much!

 

TinyPortal © 2005-2018