comparison 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
comparison
equal deleted inserted replaced
408:edfdb1d5db3c 409:41242512d544
911 if (m_paneStack->getCurrentPane() && 911 if (m_paneStack->getCurrentPane() &&
912 m_paneStack->getCurrentPane()->getSelectedLayer()) { 912 m_paneStack->getCurrentPane()->getSelectedLayer()) {
913 913
914 Layer *layer = m_paneStack->getCurrentPane()->getSelectedLayer(); 914 Layer *layer = m_paneStack->getCurrentPane()->getSelectedLayer();
915 915
916 if (m_viewManager && 916 if (m_viewManager) {
917 (m_viewManager->getToolMode() == ViewManager::MeasureMode)) { 917
918 918 if (m_viewManager->getToolMode() == ViewManager::MeasureMode) {
919 layer->deleteCurrentMeasureRect(); 919
920 920 layer->deleteCurrentMeasureRect();
921 } else {
922
923 MultiSelection::SelectionList selections =
924 m_viewManager->getSelections();
925 921
926 for (MultiSelection::SelectionList::iterator i = selections.begin(); 922 } else {
927 i != selections.end(); ++i) { 923
928 layer->deleteSelection(*i); 924 MultiSelection::SelectionList selections =
925 m_viewManager->getSelections();
926
927 for (MultiSelection::SelectionList::iterator i = selections.begin();
928 i != selections.end(); ++i) {
929 layer->deleteSelection(*i);
930 }
929 } 931 }
930 } 932 }
931 } 933 }
932 } 934 }
933 935
1008 bool havePrevPoint = false; 1010 bool havePrevPoint = false;
1009 1011
1010 SparseOneDimensionalModel::EditCommand *command = 1012 SparseOneDimensionalModel::EditCommand *command =
1011 new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point")); 1013 new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point"));
1012 1014
1013 if (m_labeller->requiresPrevPoint()) { 1015 if (m_labeller) {
1014 1016
1015 SparseOneDimensionalModel::PointList prevPoints = 1017 if (m_labeller->requiresPrevPoint()) {
1016 sodm->getPreviousPoints(frame); 1018
1017 1019 SparseOneDimensionalModel::PointList prevPoints =
1018 if (!prevPoints.empty()) { 1020 sodm->getPreviousPoints(frame);
1019 prevPoint = *prevPoints.begin(); 1021
1020 havePrevPoint = true; 1022 if (!prevPoints.empty()) {
1023 prevPoint = *prevPoints.begin();
1024 havePrevPoint = true;
1025 }
1021 } 1026 }
1022 }
1023
1024 if (m_labeller) {
1025 1027
1026 m_labeller->setSampleRate(sodm->getSampleRate()); 1028 m_labeller->setSampleRate(sodm->getSampleRate());
1027 1029
1028 if (m_labeller->actingOnPrevPoint() && havePrevPoint) { 1030 if (m_labeller->actingOnPrevPoint() && havePrevPoint) {
1029 command->deletePoint(prevPoint); 1031 command->deletePoint(prevPoint);
1110 } 1112 }
1111 1113
1112 NoteModel *nm = dynamic_cast<NoteModel *>(layer->getModel()); 1114 NoteModel *nm = dynamic_cast<NoteModel *>(layer->getModel());
1113 if (nm) { 1115 if (nm) {
1114 NoteModel::Point point(alignedStart, 1116 NoteModel::Point point(alignedStart,
1115 rm->getValueMinimum(), 1117 nm->getValueMinimum(),
1116 alignedDuration, 1118 alignedDuration,
1117 1.f, 1119 1.f,
1118 ""); 1120 "");
1119 NoteModel::EditCommand *command = 1121 NoteModel::EditCommand *command =
1120 new NoteModel::EditCommand(nm, tr("Add Point")); 1122 new NoteModel::EditCommand(nm, tr("Add Point"));
1129 } 1131 }
1130 1132
1131 FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(layer->getModel()); 1133 FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(layer->getModel());
1132 if (fnm) { 1134 if (fnm) {
1133 FlexiNoteModel::Point point(alignedStart, 1135 FlexiNoteModel::Point point(alignedStart,
1134 rm->getValueMinimum(), 1136 fnm->getValueMinimum(),
1135 alignedDuration, 1137 alignedDuration,
1136 1.f, 1138 1.f,
1137 ""); 1139 "");
1138 FlexiNoteModel::EditCommand *command = 1140 FlexiNoteModel::EditCommand *command =
1139 new FlexiNoteModel::EditCommand(fnm, tr("Add Point")); 1141 new FlexiNoteModel::EditCommand(fnm, tr("Add Point"));
1140 command->addPoint(point); 1142 command->addPoint(point);
1141 command->setName(name); 1143 command->setName(name);
1142 c = command->finish(); 1144 c = command->finish();
1143 } 1145 }
1144 1146
1145 if (c) { 1147 if (c) {
1146 CommandHistory::getInstance()->addCommand(c, false); 1148 CommandHistory::getInstance()->addCommand(c, false);
1147 return; 1149 return;
1148 } 1150 }
1149 } 1151 }
2873 } 2875 }
2874 2876
2875 MainWindowBase::RemovePaneCommand::RemovePaneCommand(MainWindowBase *mw, Pane *pane) : 2877 MainWindowBase::RemovePaneCommand::RemovePaneCommand(MainWindowBase *mw, Pane *pane) :
2876 m_mw(mw), 2878 m_mw(mw),
2877 m_pane(pane), 2879 m_pane(pane),
2880 m_prevCurrentPane(0),
2878 m_added(true) 2881 m_added(true)
2879 { 2882 {
2880 } 2883 }
2881 2884
2882 MainWindowBase::RemovePaneCommand::~RemovePaneCommand() 2885 MainWindowBase::RemovePaneCommand::~RemovePaneCommand()