AttributeError: CvMainInterface instance has no attribute...

Spillsandstains

Warlord
Joined
Mar 31, 2008
Messages
271
hello my kittens and goslings

grovelling request for some help.

had a really odd error that i haven't seen before - the game wouldn't advance a turn, have never seen it before, it just stopped

the log "pythonerror2" seemed to indicate it was an art problem (i'm used to these, they just crash the game), so i trawled through loads of art references to find it.

i have a custom cvmaininterface (attached) so i dumped it and tried again, at the crash point, with the vanilla bts cvmaininterface. same problem, game just hangs.

i would appreciate any advice or pointers to the error, i don't have much of a social life, and it would be interesting unpicking the problem

attached is a zip file with:

errorCvMainInterface.py - the file i was using at the point of the game crashing
pythonerror2-logwithmoddedCv-m-i - the log that was generated at this point, with the error at the end
pythonerror2-logwithoutmoddedCv-m-i - the log that was generated when i reloaded with a clean vanilla cvmaininterface file... which promptly experienced the same problem, but didn't log the error in the same way
 

Attachments

  • files.rar
    25.7 KB · Views: 164
The breaking code is this:
PHP:
    def numPlotListButtons(self):
       return self.m_iNumPlotListButtons
self.m_iNumPlotListButtons is set in interfaceScreen and updateScreen
PHP:
Traceback (most recent call last):
  File "CvScreensInterface", line 705, in forceScreenRedraw
  File "CvMainInterface", line 730, in redraw
  File "CvMainInterface", line 1092, in updatePlotListButtons
  File "CvMainInterface", line 113, in numPlotListButtons
AttributeError: CvMainInterface instance has no attribute 'm_iNumPlotListButtons'
Apparently forceScreenRedraw is called where it manage to call numPlotListButtons without calling either of the functions to set the variable, meaning it doesn't exist.

PHP:
def __init__(self):
    self.m_iNumPlotListButtons = whatever default you want
__init__ should be called automatically when the class instance is allocated. This way you can ensure that the variable is always present. It might have the wrong value, which can cause the screen to be incorrect until it is redrawn later (but still before the player sees it). What's important here is that it will not cause a code breaking problem.
 
dear nightingale

thank you very much for that. in your experience, what typically causes the problem?
 
Top Bottom