From 06a45d8a8896f45bf732c12dbb15bae931ff7d9b Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sat, 2 Sep 2017 15:14:40 -0700 Subject: [PATCH] Fixed error stock from existing when selected again. --- src/Mod/Path/PathScripts/PathJobGui.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index 8defe4fb2c..34bf4d5dd6 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -302,17 +302,17 @@ class StockFromExistingEdit(StockEdit): self.setStock(obj, stock) def setFields(self, obj): + self.form.stockExisting.clear() + candidates = [o for o in obj.Document.Objects if PathUtil.isSolid(o)] - candidates.remove(obj.Base) - if PathJob.isResourceClone(obj, 'Stock', 'Stock'): - candidates.remove(obj.Stock) + candidates.remove(obj.Base) # always a resource clone + candidates.remove(obj.Stock) # regardless, what stock is/was, it's not a valid choice stockName = obj.Stock.Label if obj.Stock else None - self.form.stockExisting.clear() index = -1 - for i, c in enumerate(candidates): - self.form.stockExisting.addItem(c.Label, c) - if c.Label == stockName: + for i, o in enumerate(sorted(candidates, key=lambda c: c.Label)): + self.form.stockExisting.addItem(o.Label, o) + if o.Label == stockName: index = i self.form.stockExisting.setCurrentIndex(index if index != -1 else 0)