Skip to content

Commit

Permalink
Fix some bugs with notes view - exception happening due to lack of fi…
Browse files Browse the repository at this point in the history
…t, and possibility of notes saving under the wrong fit
  • Loading branch information
blitzmann committed Apr 13, 2017
1 parent 5aeb3a3 commit e28bf54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gui/notesView.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ def fitChanged(self, event):
sFit = Fit.getInstance()
fit = sFit.getFit(event.fitID)

self.saveTimer.Stop() # cancel any pending timers

self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)

# when switching fits, ensure that we save the notes for the previous fit
if self.lastFitId is not None:
sFit.editNotes(self.lastFitId, self.editNotes.GetValue())

if event.fitID is None and self.lastFitId is not None:
self.lastFitId = None
event.Skip()
Expand All @@ -41,7 +47,4 @@ def onText(self, event):

def delayedSave(self, event):
sFit = Fit.getInstance()
fit = sFit.getFit(self.lastFitId)
newNotes = self.editNotes.GetValue()
fit.notes = newNotes
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fit.ID))
sFit.editNotes(self.lastFitId, self.editNotes.GetValue())
6 changes: 6 additions & 0 deletions service/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ def clearFit(fitID):
fit.clear()
return fit

@staticmethod
def editNotes(fitID, notes):
fit = eos.db.getFit(fitID)
fit.notes = notes
eos.db.commit()

def toggleFactorReload(self, fitID):
pyfalog.debug("Toggling factor reload for fit ID: {0}", fitID)
if fitID is None:
Expand Down

0 comments on commit e28bf54

Please sign in to comment.