From e8a7b18293768497df272bb4cb64b678d57f58da Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 27 Aug 2017 09:53:18 -0400 Subject: [PATCH] disallow suspiciously enormous floats this stops a bad project file from crashing my computer... --- src/component.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/component.py b/src/component.py index de4b6a7..01c1d06 100644 --- a/src/component.py +++ b/src/component.py @@ -390,7 +390,7 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): self.settings = parent.settings log.verbose( 'Creating UI for %s #%s\'s widget', - self.name, self.compPos + self.__class__.name, self.compPos ) self.page = self.loadUi(self.__class__.ui) @@ -533,7 +533,8 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): else: # Normal tracked widget setattr(self, attr, val) - log.verbose('Setting %s self.%s to %s' % (self.name, attr, val)) + log.verbose('Setting %s self.%s to %s' % ( + self.__class__.name, attr, val)) def setWidgetValues(self, attrDict): ''' @@ -698,6 +699,12 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): def pixelValForAttr(self, attr, val=None, **kwargs): if val is None: val = self._relativeValues[attr] + if val > 50.0: + log.warning( + '%s #%s attempted to set %s to dangerously high number %s', + self.__class__.name, self.compPos, attr, val + ) + val = 50.0 result = math.ceil(kwargs['axis'] * val) log.verbose( 'Converting %s: f%s to px%s using axis %s', @@ -748,7 +755,7 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass): # means the pixel value needs to be updated log.debug( 'Updating %s #%s\'s relative widget: %s', - self.name, self.compPos, attr) + self.__class__.name, self.compPos, attr) with blockSignals(self._trackedWidgets[attr]): self.updateRelativeWidgetMaximum(attr) pixelVal = self.pixelValForAttr(attr, oldRelativeVal)