Add eval() to distance line edit during scaling

This adds the ability to enter things like 6 * 25.4 into the distance line edit widget during scaling operations in the image workbench.  Can also enter something like math.pi * 3 or 2**3, etc.  Basically, any legal python input can be used.

Using eval() is not considered a secure way of doing things, but in this context the user would be entering malicious code into his own computer.  Also, what can the user do in eval() that he can't already do just by entering directly into the python console?
This commit is contained in:
Mark Ganson TheMarkster
2018-09-01 18:16:48 -05:00
committed by GitHub
parent 2e2b8cba6a
commit 09dc6d3021

View File

@@ -139,7 +139,7 @@ def cmdCreateImageScaling(name):
sel = FreeCADGui.Selection.getSelection()
try:
locale=QtCore.QLocale.system()
d, ok = locale.toFloat(self.lineEdit.text())
d, ok = locale.toFloat(str(eval(self.lineEdit.text())))
if not ok:
raise ValueError
s=d/self.distance