Make command-related commands and their invokations more reliable

This commit is contained in:
DarkPhoenix
2019-04-20 00:35:14 +03:00
parent fda83bcb49
commit 93cd3b97fa
5 changed files with 14 additions and 7 deletions

View File

@@ -99,14 +99,17 @@ class CommandView(d.Display):
fitID = self.mainFrame.getActiveFit()
row = self.GetFirstSelected()
if row != -1:
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(fitID, self.get(row).ID))
commandFit = self.get(row)
if commandFit is not None:
self.mainFrame.command.Submit(cmd.GuiRemoveCommandFitCommand(
fitID=fitID, commandFitID=commandFit.ID))
def handleDrag(self, type, fitID):
# Those are drags coming from pyfa sources, NOT builtin wx drags
if type == "fit":
activeFit = self.mainFrame.getActiveFit()
if activeFit:
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, fitID))
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=activeFit, commandFitID=fitID))
def startDrag(self, event):
row = event.GetIndex()

View File

@@ -98,7 +98,7 @@ class AddCommandFit(ContextMenu):
return
fitID = self.mainFrame.getActiveFit()
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID, fit.ID))
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=fitID, commandFitID=fit.ID))
AddCommandFit.populateFits(None)

View File

@@ -185,13 +185,13 @@ class FitItem(SFItem.SFBrowserItem):
if activeFit:
sFit = Fit.getInstance()
projectedFit = sFit.getFit(self.fitID)
if self.mainFrame.command.Submit(cmd.GuiAddProjectedCommand(activeFit, projectedFit.ID, 'fit')):
if self.mainFrame.command.Submit(cmd.GuiAddProjectedFitCommand(fitID=activeFit, projectedFitID=projectedFit.ID)):
self.mainFrame.additionsPane.select("Projected")
def OnAddCommandFit(self, event):
activeFit = self.mainFrame.getActiveFit()
if activeFit:
if self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(activeFit, self.fitID)):
if self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=activeFit, commandFitID=self.fitID)):
self.mainFrame.additionsPane.select("Command")
def OnMouseCaptureLost(self, event):

View File

@@ -30,7 +30,9 @@ class CalcAddCommandCommand(wx.Command):
if commandFit in fit.commandFits:
pyfalog.debug('Command fit had been applied already')
return False
if commandFit.ID in fit.commandFitDict:
pyfalog.debug('Commanding fit is in command dict already')
return False
fit.commandFitDict[commandFit.ID] = commandFit
# This bit is required, see issue #83
eos.db.saveddata_session.flush()

View File

@@ -30,8 +30,10 @@ class CalcRemoveCommandCommand(wx.Command):
if commandInfo is None:
pyfalog.warning('Fit command info is not available')
return False
self.savedState = commandInfo.active
if commandFit.ID not in fit.commandFitDict:
pyfalog.warning('Unable to find commanding fit in command dict')
return False
del fit.commandFitDict[commandFit.ID]
eos.db.commit()
return True