Skip to content

Commit fd50ec8

Browse files
committed
qtvcp -fix embedded panel instance reference
Widget reference to INSTANCE was always the main screen. Now INSTANCE refers to the panel's instance. The main screen instance reference is available as MAIN_INSTANCE
1 parent 37209d9 commit fd50ec8

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

lib/python/qtvcp/qt_makepins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def __init__(self, halcomp, path, window, debug):
112112
idname = widget.objectName()
113113
LOG.verbose('{}: HAL-ified widget: {}'.format(name.upper(), idname))
114114
if not isinstance(widget, ScreenOptions):
115-
widget.hal_init()
115+
# give panel name to halified widgets
116+
widget.hal_init(INSTANCE_NAME= pName)
116117

117118
# restore HAL component name
118119
halcomp.comp.setprefix(oldname)

lib/python/qtvcp/widgets/simple_widgets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ def _hal_init(self):
411411
self.hal_pin_led.value_changed.connect(lambda data: self.indicator_update(data))
412412
elif self._ind_status:
413413
self._init_state_change()
414-
self._globalParameter = {'__builtins__' : None, 'INSTANCE':self.QTVCP_INSTANCE_,
414+
self._globalParameter = {'__builtins__' : None, 'MAIN_INSTANCE':self.QTVCP_INSTANCE_,
415+
'INSTANCE':self.THIS_INSTANCE_,
415416
'PROGRAM_LOADER':AUX_PRGM, 'ACTION':ACTION, 'HAL':hal, 'print':print}
416417
self._localsParameter = {'dir': dir, 'True':True, 'False':False}
417418

lib/python/qtvcp/widgets/widget_baseclass.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ def __init__(self,comp=None,path=None,window=None):
4949
#print self.__class__._instanceNum >=1
5050
#print 'comp',comp,self.__class__._instanceNum
5151

52-
53-
def hal_init(self, HAL_NAME=None):
52+
# INSTANCE_NAME is the embedded panel name
53+
def hal_init(self, HAL_NAME=None,INSTANCE_NAME = None):
5454
self.__class__.QTVCP_INSTANCE_.registerHalWidget(self)
55+
if INSTANCE_NAME is not None:
56+
self.__class__.THIS_INSTANCE_ = self.__class__.QTVCP_INSTANCE_[INSTANCE_NAME]
57+
else:
58+
self.__class__.THIS_INSTANCE_ = self.__class__.QTVCP_INSTANCE_
5559
if HAL_NAME is not None:
5660
self.HAL_NAME_ = str(HAL_NAME)
5761
else:

0 commit comments

Comments
 (0)