disallow suspiciously enormous floats

this stops a bad project file from crashing my computer...
This commit is contained in:
tassaron 2017-08-27 09:53:18 -04:00
parent 85d3b779d0
commit e8a7b18293
1 changed files with 10 additions and 3 deletions

View File

@ -390,7 +390,7 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
self.settings = parent.settings self.settings = parent.settings
log.verbose( log.verbose(
'Creating UI for %s #%s\'s widget', 'Creating UI for %s #%s\'s widget',
self.name, self.compPos self.__class__.name, self.compPos
) )
self.page = self.loadUi(self.__class__.ui) self.page = self.loadUi(self.__class__.ui)
@ -533,7 +533,8 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
else: else:
# Normal tracked widget # Normal tracked widget
setattr(self, attr, val) 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): def setWidgetValues(self, attrDict):
''' '''
@ -698,6 +699,12 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
def pixelValForAttr(self, attr, val=None, **kwargs): def pixelValForAttr(self, attr, val=None, **kwargs):
if val is None: if val is None:
val = self._relativeValues[attr] 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) result = math.ceil(kwargs['axis'] * val)
log.verbose( log.verbose(
'Converting %s: f%s to px%s using axis %s', '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 # means the pixel value needs to be updated
log.debug( log.debug(
'Updating %s #%s\'s relative widget: %s', 'Updating %s #%s\'s relative widget: %s',
self.name, self.compPos, attr) self.__class__.name, self.compPos, attr)
with blockSignals(self._trackedWidgets[attr]): with blockSignals(self._trackedWidgets[attr]):
self.updateRelativeWidgetMaximum(attr) self.updateRelativeWidgetMaximum(attr)
pixelVal = self.pixelValForAttr(attr, oldRelativeVal) pixelVal = self.pixelValForAttr(attr, oldRelativeVal)