Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with inheritance
#1
Hi All,

I have inherited some code and am in the process of familiarizing myself with it I have gotten stuck. When Trying to the run the code I get the following exception:

2018-10-04 13:16:40 [ERROR ] milkhub.py line:388 unhandledExceptionHandler Unhandled exception occurred:
2018-10-04 13:16:40 [ERROR ] milkhub.py line:389 unhandledExceptionHandler Type: <type 'exceptions.TypeError'>
2018-10-04 13:16:40 [ERROR ] milkhub.py line:390 unhandledExceptionHandler Value: C++ object is not yet constructed, or already destructed.
2018-10-04 13:16:40 [ERROR ] milkhub.py line:393 unhandledExceptionHandler Stack trace: File "milkhub.py", line 415, in <module>

File "/home/daniel/milkhub-dev/MILKHUBGUI/2.5/src/gui/overlays.py", line 170, in __init__
self.name = name


Starting at the 'top':
# initialise pixel2d
GuiManager.pixel2d = overlays.PixelNode(app, "g2d")
the __init__ function:
class PixelNode(OverlayContainer, NodePath):
    # class variables
    app = None
    def __init__(self, app, name=None, parent=None):
        PixelNode.app = app
        OverlayContainer.__init__(self, name)
        NodePath.__init__(self, self.name)
        if parent is None:
            parent = PixelNode.app.render2d
        self.node = self
        self.reparentTo(parent)
        self.setPos(-1,0,1) #the upper left corner
        self.aspectRatioChanged()
which finally calls the __init__ function that throws the exception:
class OverlayContainer(object):
    def __init__(self, name=None, noNode=False, flip=False):
        if name is None:
            name = '%s%i' % (self.__class__.__name__, id(self))
        [b]self.name = name[/b]
        self.node = None if noNode else NodePath(self.name)
        self.x, self.y = 0, 0
        self.zIndex = 0
        self.xScale, self.yScale = 1, 1
        self.flip = flip
        self.yMult = -1 if flip else 1
        if self.node is not None:
            self.node.setScale(self.xScale, 1, self.yScale*self.yMult)
            self.node.setBin('fixed', self.zIndex)
I have no idea why this is happening. If I replace self.name with self.name2 the script will work and throw an exception on the following line "self.node ..."

If anyone has any insights it would be very much appreciated.
Reply


Messages In This Thread
Issue with inheritance - by Danieltr - Oct-04-2018, 12:27 AM
RE: Issue with inheritance - by Larz60+ - Oct-04-2018, 02:21 AM
RE: Issue with inheritance - by Danieltr - Oct-04-2018, 07:55 PM
RE: Issue with inheritance - by nilamo - Oct-04-2018, 08:30 PM
RE: Issue with inheritance - by stullis - Oct-05-2018, 12:21 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020