Using .destroy() on ShowBase and letting go of all references should allow recreating it

Bug #1339701 reported by ellie
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
rdb

Bug Description

This test reproduces the issue:

import unittest
from direct.showbase.ShowBase import ShowBase

class TestPanda(unittest.TestCase):
    def test_panda(self):
        self.base = ShowBase()
        self.base.destroy()
        del(self.base)
        self.base = ShowBase()
        self.base.destroy()
        del(self.base)

    """ Resulting error:

    Traceback (most recent call last):
     File "map_test.py", line 55, in test_panda
       self.base = ShowBase()
     File "C:\Panda3D-1.9.0-x64\direct\showbase\ShowBase.py", line 316, in __init__

       raise StandardError, "Attempt to spawn multiple ShowBase instances!"
    StandardError: Attempt to spawn multiple ShowBase instances!

    """

Revision history for this message
rdb (rdb) wrote :

Updating this to let you know I haven't forgotten about this. I've got this mostly figured out so far, there's still one reference I'm trying to track down that is causing ShowBase to leak.

Changed in panda3d:
assignee: nobody → rdb (rdb)
milestone: none → 1.9.0
status: New → In Progress
Revision history for this message
rdb (rdb) wrote :

I found out what caused it to leak: when the tasks were removed, removal events get fired off and unless the event queue is explicitly flushed they keep a reference to the task (which keep a reference to ShowBase).

So, I can now start and destroy ShowBase multiple times. It's still advisable to call gc.collect() in between so that you clear up any cyclic references.

Changed in panda3d:
status: In Progress → Fix Committed
rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers