Mercurial > hg > svapp
diff framework/MainWindowBase.cpp @ 409:41242512d544
Fix one actual null pointer deref and a couple of potential ones, plus an uninitialised value (from coverity scan)
author | Chris Cannam |
---|---|
date | Wed, 03 Sep 2014 09:35:56 +0100 |
parents | eb84b06301da |
children | a39a7d6b0f2d |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed Sep 03 09:27:04 2014 +0100 +++ b/framework/MainWindowBase.cpp Wed Sep 03 09:35:56 2014 +0100 @@ -913,19 +913,21 @@ Layer *layer = m_paneStack->getCurrentPane()->getSelectedLayer(); - if (m_viewManager && - (m_viewManager->getToolMode() == ViewManager::MeasureMode)) { - - layer->deleteCurrentMeasureRect(); - - } else { - - MultiSelection::SelectionList selections = - m_viewManager->getSelections(); + if (m_viewManager) { + + if (m_viewManager->getToolMode() == ViewManager::MeasureMode) { + + layer->deleteCurrentMeasureRect(); - for (MultiSelection::SelectionList::iterator i = selections.begin(); - i != selections.end(); ++i) { - layer->deleteSelection(*i); + } else { + + MultiSelection::SelectionList selections = + m_viewManager->getSelections(); + + for (MultiSelection::SelectionList::iterator i = selections.begin(); + i != selections.end(); ++i) { + layer->deleteSelection(*i); + } } } } @@ -1010,18 +1012,18 @@ SparseOneDimensionalModel::EditCommand *command = new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point")); - if (m_labeller->requiresPrevPoint()) { - - SparseOneDimensionalModel::PointList prevPoints = - sodm->getPreviousPoints(frame); - - if (!prevPoints.empty()) { - prevPoint = *prevPoints.begin(); - havePrevPoint = true; + if (m_labeller) { + + if (m_labeller->requiresPrevPoint()) { + + SparseOneDimensionalModel::PointList prevPoints = + sodm->getPreviousPoints(frame); + + if (!prevPoints.empty()) { + prevPoint = *prevPoints.begin(); + havePrevPoint = true; + } } - } - - if (m_labeller) { m_labeller->setSampleRate(sodm->getSampleRate()); @@ -1112,7 +1114,7 @@ NoteModel *nm = dynamic_cast<NoteModel *>(layer->getModel()); if (nm) { NoteModel::Point point(alignedStart, - rm->getValueMinimum(), + nm->getValueMinimum(), alignedDuration, 1.f, ""); @@ -1131,17 +1133,17 @@ FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(layer->getModel()); if (fnm) { FlexiNoteModel::Point point(alignedStart, - rm->getValueMinimum(), - alignedDuration, - 1.f, - ""); + fnm->getValueMinimum(), + alignedDuration, + 1.f, + ""); FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand(fnm, tr("Add Point")); command->addPoint(point); command->setName(name); c = command->finish(); } - + if (c) { CommandHistory::getInstance()->addCommand(c, false); return; @@ -2875,6 +2877,7 @@ MainWindowBase::RemovePaneCommand::RemovePaneCommand(MainWindowBase *mw, Pane *pane) : m_mw(mw), m_pane(pane), + m_prevCurrentPane(0), m_added(true) { }