Mercurial > hg > svgui
changeset 762:b75c95e7f906 tonioni
Fix potential for crash on reloading session file - loading selections should not emit signal as if user had just made them manually
author | Chris Cannam |
---|---|
date | Thu, 03 Apr 2014 08:51:30 +0100 |
parents | 6a8d922f991d |
children | 6388ddae6ce3 |
files | view/ViewManager.cpp view/ViewManager.h |
diffstat | 2 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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