このプロジェクトの編集:https://github.com/Roland00111/Trumpocalypse/tree/Recursion/Trumpoclypse%20UIプログラムはpython Trumpocalypse.py
で開始します。Pygame segmentation fault:分類と再帰に関する問題?
エラーがある:別のマシン上で
Fatal Python error: (pygame parachute) Segmentation Fault
Aborted (core dumped)
最大再帰の深さについての出力があります。再帰が発生する可能性のある場所がいくつかあります。
メニューと呼ばれるクラス内で呼び出されるイベントループ中のpygameがあります。 Enterキーが押されるたびに、イベントループが停止します。次に、新しいMenuクラスが呼び出されます。そして、この新しいMenuクラスは新しいwhileイベントループを開始します。 Menuクラスは、すべてメインメニュークラスのサブクラスです。
新しいメニュークラスが前のメニュー内で開始されるたびに、再帰が発生する可能性があります。
たとえば、Menu:OpeningMenu()は、イベントループの最初の部分を実行します。 最初の項目が選択されている場合メニュー:CreateCharacter()はイベントループ中に新しいイベントを実行します。 次に、2番目のアイテムが選択されている場合Menu:CreateCharacterAutomatic()はイベントループ中に新しいイベントを実行します。 最初のアイテムが選択されている場合メニュー:StoryScreen()はイベントループ中に新しいイベントを実行します。 そして、最初の項目を約60回選択します。これにより、Menu:StoryScreen()とMenu:DayScreen()の新しいインスタンスが交互に切り替わります。約60時間後、セグメンテーションが発生します。
興味深いのは、Menu:DayScreen()コードの前のどこかを反復するときにsegfaultが発生しないように見えることです。 Menu:OpeningMenu()からMenu:HighScores()に戻り、無限に戻ってもsegfaultは発生しません。しかし、ここで興味深いものがあります:Menu:DayScreen()の最初のインスタンスに行くとすぐにsegfaults。つまり、最初にMenu:DayScreen()を開いたときに何か60の何らかのカウンタが設定されていれば、セグメンテーションが実際に発生します。
previous_menu.__del__()
を実行しても問題は解決しないようです。これは実際に前のメニューを終了しますが、Menu:DayScreen()の間に発生するセグメンテーションフォールトは依然として存在します。
更新
は今見て:
RuntimeError: maximum recursion depth exceeded while getting the str of an object
これは、すべての継承するクラスのメニューのための2つのコールを実施した後、次のとおりです。
previous_menuが開始し、最後のMenuインスタンスですMenu.__init__(self)
previous_menu.__del__()
現在のインスタンス。これはPygameの問題か、コードがPythonのクラスをどのように呼び出しているかの問題ですか?
バグを再現するには:「開始」を選択し、「自動」を選択し、「あなたのアドベンチャーを開始」を選択し、「開始日」を選択し、「次の日」を選択します。今度は、「Start Day」と「Next Day」を約120回(それぞれ60回)続けます。この時点で、再帰バグが発生します。ここで
がフル出力である:
Traceback (most recent call last):
File "Trumpocalypse.py", line 826, in <module>
GameState()
File "Trumpocalypse.py", line 495, in __init__
self.current_screen = OpeningMenu() # Start the events while loop.
File "Trumpocalypse.py", line 789, in __init__
self.keypressFunction()
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 766, in __init__
self.keypressFunction()
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 638, in __init__
self.keypressFunction(Text,32)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
self.keypressFunction(text,32,20,300) #Looks the same as highscore
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 745, in __init__
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 725, in __init__
...
self.keypressFunction(text,32,60,250) # Pass text (text,font size,top allignment,height of box)
File "Trumpocalypse.py", line 275, in keypressFunction
self.keypressArray[chosen_position](self)
File "Trumpocalypse.py", line 689, in __init__
Menu.__init__(self)
RuntimeError: maximum recursion depth exceeded while calling a Python object
__del__ <__main__.DayScreen instance at 0x7f7bee5eddd0>
__del__ <__main__.StoryScreen instance at 0x7f7bee5edcb0>
__del__ <__main__.DayScreen instance at 0x7f7bee5edb00>
__del__ <__main__.StoryScreen instance at 0x7f7bee5ed9e0>
__del__ <__main__.DayScreen instance at 0x7f7bee5ed830>
__del__ <__main__.StoryScreen instance at 0x7f7bee5ed710>
__del__ <__main__.DayScreen instance at 0x7f7bee5ed560>
__del__ <__main__.StoryScreen instance at 0x7f7bee5ed440>
__del__ <__main__.DayScreen instance at 0x7f7bee5ed290>
__del__ <__main__.StoryScreen instance at 0x7f7bee5ed170>
__del__ <__main__.DayScreen instance at 0x7f7bee5e7f80>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e7e60>
__del__ <__main__.DayScreen instance at 0x7f7bee5e7cb0>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e7b90>
__del__ <__main__.DayScreen instance at 0x7f7bee5e79e0>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e78c0>
__del__ <__main__.DayScreen instance at 0x7f7bee5e7710>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e75f0>
__del__ <__main__.DayScreen instance at 0x7f7bee5e7440>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e7320>
__del__ <__main__.DayScreen instance at 0x7f7bee5e7170>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e7050>
__del__ <__main__.DayScreen instance at 0x7f7bee5e1e60>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e1d40>
__del__ <__main__.DayScreen instance at 0x7f7bee5e1b90>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e1a70>
__del__ <__main__.DayScreen instance at 0x7f7bee5e18c0>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e17a0>
__del__ <__main__.DayScreen instance at 0x7f7bee5e15f0>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e14d0>
__del__ <__main__.DayScreen instance at 0x7f7bee5e1320>
__del__ <__main__.StoryScreen instance at 0x7f7bee5e1200>
__del__ <__main__.DayScreen instance at 0x7f7bee5e1050>
__del__ <__main__.StoryScreen instance at 0x7f7bee659ef0>
__del__ <__main__.DayScreen instance at 0x7f7bee659d40>
__del__ <__main__.StoryScreen instance at 0x7f7bee659c20>
__del__ <__main__.DayScreen instance at 0x7f7bee659a70>
__del__ <__main__.StoryScreen instance at 0x7f7bee659950>
__del__ <__main__.DayScreen instance at 0x7f7bee6597a0>
__del__ <__main__.StoryScreen instance at 0x7f7bee659680>
__del__ <__main__.DayScreen instance at 0x7f7bee6594d0>
...
__del__ <__main__.StoryScreen instance at 0x7f7bee92bd40>
__del__ <__main__.DayScreen instance at 0x7f7bef066710>
__del__ <__main__.StoryScreen instance at 0x7f7bef08e6c8>
__del__ <__main__.CreateCharacterAutomatic instance at 0x7f7bee92b638>
__del__ <__main__.CreateCharacter instance at 0x7f7bee92b9e0>
__del__ <__main__.OpeningMenu instance at 0x7f7bee6b3b48>
ソリューション
クラスが別のクラスを呼び出すため、再帰ました。 (自分自身を終了するには、親が働いていないか、正しく実装されていなかったのどちらか指示する子供のために子供に親インスタンスを渡す。)例:
class Menu1():
def __init__(self):
Menu2(self)
class Menu2():
def __init__(self, previous):
previous.__del__() # Not working.
今のところ解決策は、親クラスが直接持っていることです呼び出すクラス。例:
class Menu1():
def __init__(self):
pass
class Menu2():
def __init__(self):
pass
a=Menu1()
a=Menu2()
これは機能し、再帰で問題にはなりません。
大丈夫です。面白い。 – There
だから、いくつかの変更を加え、それは今実行しているようだ。 – There
問題:各クラスが別のクラスを呼び出していたため、実際には終了しませんでした。例えば。 'Menu1()。some_function:Menu2()'。 解決方法:親クラスでどのクラスを呼び出すかを指示します。例えば。 'a = Menu1()'そして 'a = Menu2()'です。 – There