plcopen/InstancesPathCollector.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sat, 25 Nov 2023 00:18:05 +0100
changeset 3880 89549813a6c1
parent 3751 a80a66ba52d6
permissions -rw-r--r--
SVGHMI: Fixes UI lifecycle problems

Was sometime showing HMI tree of previously closed project : no more module globals to store hmi tree.
C++ dead object exceptions happened when re-opening SVGHMI UI or building after close of UI.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of Beremiz.
# See COPYING file for copyrights details.


from . XSLTModelQuery import XSLTModelQuery


class InstancesPathCollector(XSLTModelQuery):
    """ object for collecting instances path list"""
    def __init__(self, controller):
        self.Instances = []
        XSLTModelQuery.__init__(self,
                                controller,
                                "instances_path.xslt",
                                [("AddInstance", self.AddInstance)])

    def AddInstance(self, context, *args):
        self.Instances.append(args[0][0])

    def Collect(self, root, name, debug):
        self._process_xslt(root, debug, instance_type=name)
        res = self.Instances
        self.Instances = []
        return res