# HG changeset patch # User Chris Cannam # Date 1396511490 -3600 # Node ID b75c95e7f9064c4326f327bd9e182946049c7194 # Parent 6a8d922f991d5e96b97f79ca0e4f20fd66e03462 Fix potential for crash on reloading session file - loading selections should not emit signal as if user had just made them manually diff -r 6a8d922f991d -r b75c95e7f906 view/ViewManager.cpp --- a/view/ViewManager.cpp Wed Apr 02 21:50:04 2014 +0100 +++ b/view/ViewManager.cpp Thu Apr 03 08:51:30 2014 +0100 @@ -258,6 +258,14 @@ } void +ViewManager::addSelectionQuietly(const Selection &selection) +{ + MultiSelection ms(m_selections); + ms.addSelection(selection); + setSelections(ms, true); +} + +void ViewManager::removeSelection(const Selection &selection) { MultiSelection ms(m_selections); @@ -274,12 +282,14 @@ } void -ViewManager::setSelections(const MultiSelection &ms) +ViewManager::setSelections(const MultiSelection &ms, bool quietly) { if (m_selections.getSelections() == ms.getSelections()) return; SetSelectionCommand *command = new SetSelectionCommand(this, ms); CommandHistory::getInstance()->addCommand(command); - emit selectionChangedByUser(); + if (!quietly) { + emit selectionChangedByUser(); + } } size_t diff -r 6a8d922f991d -r b75c95e7f906 view/ViewManager.h --- a/view/ViewManager.h Wed Apr 02 21:50:04 2014 +0100 +++ b/view/ViewManager.h Thu Apr 03 08:51:30 2014 +0100 @@ -86,6 +86,13 @@ size_t constrainFrameToSelection(size_t frame) const; /** + * Adding a selection normally emits the selectionChangedByUser + * signal. Call this to add a selection without emitting that signal. + * This is used in session file load, for example. + */ + void addSelectionQuietly(const Selection &selection); + + /** * Return the selection that contains a given frame. * If defaultToFollowing is true, and if the frame is not in a * selected area, return the next selection after the given frame. @@ -297,7 +304,7 @@ bool m_playSoloMode; bool m_alignMode; - void setSelections(const MultiSelection &ms); + void setSelections(const MultiSelection &ms, bool quietly = false); void signalSelectionChange(); class SetSelectionCommand : public Command