From 71ca7d153e1983294775188d29cfc85d4d125084 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Feb 2017 08:59:54 -0800 Subject: [PATCH 1/3] Check if we have active drones when merging, if we do make them all active to avoid getting weird scenarios (like deactivating stacks, or only activating parts of stacks). Fixes #728 --- gui/droneView.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gui/droneView.py b/gui/droneView.py index cb08f8d1d..44ed90ebf 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -147,6 +147,12 @@ class DroneView(Display): def _merge(self, src, dst): sFit = Fit.getInstance() fitID = self.mainFrame.getActiveFit() + + # If either stack has active drones, make them all active. Fixes #728 + if (getattr(self.drones[src], "amountActive", 0) + getattr(self.drones[dst], "amountActive", 0)) > 0: + self.drones[src].amountActive = getattr(self.drones[src], "amount", 0) + self.drones[dst].amountActive = getattr(self.drones[dst], "amount", 0) + if sFit.mergeDrones(fitID, self.drones[src], self.drones[dst]): wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) From 489637ec67687f0505d41f3ed6dc8095ebdb2a84 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Feb 2017 09:20:22 -0800 Subject: [PATCH 2/3] Handle this at a lower level. --- gui/droneView.py | 5 ----- service/fit.py | 10 ++++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gui/droneView.py b/gui/droneView.py index 44ed90ebf..e506c278d 100644 --- a/gui/droneView.py +++ b/gui/droneView.py @@ -148,11 +148,6 @@ class DroneView(Display): sFit = Fit.getInstance() fitID = self.mainFrame.getActiveFit() - # If either stack has active drones, make them all active. Fixes #728 - if (getattr(self.drones[src], "amountActive", 0) + getattr(self.drones[dst], "amountActive", 0)) > 0: - self.drones[src].amountActive = getattr(self.drones[src], "amount", 0) - self.drones[dst].amountActive = getattr(self.drones[dst], "amount", 0) - if sFit.mergeDrones(fitID, self.drones[src], self.drones[dst]): wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) diff --git a/service/fit.py b/service/fit.py index 719fb7b6a..409f2e932 100644 --- a/service/fit.py +++ b/service/fit.py @@ -726,8 +726,14 @@ class Fit(object): else: fit.drones.remove(d1) - d2.amount += d1.amount - d2.amountActive += d1.amountActive if d1.amountActive > 0 else -d2.amountActive + d2.amount += getattr(d1, "amount", 0) + d2.amountActive += getattr(d1, "amountActive", 0) + + # If we have less than the total number of drones active, make them all active. Fixes #728 + # This could be removed if we ever add an enhancement to make drone stacks partially active. + if getattr(d2, "amount", 0) > getattr(d2, "amountActive", 0): + d2.amountActive = getattr(d2, "amount", 0) + eos.db.commit() self.recalc(fit) return True From a86502842051854719e4cf5605ef100ace5a8f15 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Wed, 15 Feb 2017 15:42:46 -0800 Subject: [PATCH 3/3] Remove litter. --- service/fit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/fit.py b/service/fit.py index 409f2e932..2b87fefd3 100644 --- a/service/fit.py +++ b/service/fit.py @@ -731,8 +731,8 @@ class Fit(object): # If we have less than the total number of drones active, make them all active. Fixes #728 # This could be removed if we ever add an enhancement to make drone stacks partially active. - if getattr(d2, "amount", 0) > getattr(d2, "amountActive", 0): - d2.amountActive = getattr(d2, "amount", 0) + if d2.amount > d2.amountActive: + d2.amountActive = d2.amount eos.db.commit() self.recalc(fit)