From 9c9867dec527e3d0231a71c043fd9dc9b894a339 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 12 Feb 2014 06:07:32 -0800 Subject: More variable scope confusions Don't have nested loops with the same loop variable. Really. Even if it is legal C++. And don't declare local variables more than once. This will only cause issues later. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 85cf1b192..b65d572fd 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -147,7 +147,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE)) continue; bool checked = s.value(QString("column%1_hidden").arg(i)).toBool(); - QAction *action = new QAction(cylindersModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(), ui.cylinders->view()); + action = new QAction(cylindersModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(), ui.cylinders->view()); action->setCheckable(true); action->setData(i); action->setChecked(!checked); @@ -281,11 +281,11 @@ void MainTab::enableEdition(EditMode newEditMode) notesBackup[mydive].tags = QString(buf); // maybe this is a place for memset? - for (int i = 0; i < MAX_CYLINDERS; i++) { - notesBackup[mydive].cylinders[i] = mydive->cylinder[i]; + for (int j = 0; j < MAX_CYLINDERS; j++) { + notesBackup[mydive].cylinders[j] = mydive->cylinder[j]; } - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { - notesBackup[mydive].weightsystem[i] = mydive->weightsystem[i]; + for (int j = 0; j < MAX_WEIGHTSYSTEMS; j++) { + notesBackup[mydive].weightsystem[j] = mydive->weightsystem[j]; } } @@ -767,11 +767,11 @@ void MainTab::rejectChanges() mydive->visibility = notesBackup[mydive].visibility; // maybe this is a place for memset? - for (int i = 0; i < MAX_CYLINDERS; i++) { - mydive->cylinder[i] = notesBackup[mydive].cylinders[i]; + for (int j = 0; j < MAX_CYLINDERS; j++) { + mydive->cylinder[j] = notesBackup[mydive].cylinders[j]; } - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) { - mydive->weightsystem[i] = notesBackup[mydive].weightsystem[i]; + for (int j = 0; j < MAX_WEIGHTSYSTEMS; j++) { + mydive->weightsystem[j] = notesBackup[mydive].weightsystem[j]; } } updateGpsCoordinates(curr); @@ -813,8 +813,8 @@ void MainTab::rejectChanges() if (editMode == NONE) \ return; \ \ - for (int i = 0; i < dive_table.nr; i++) { \ - struct dive *mydive = get_dive(i); \ + for (int _i = 0; _i < dive_table.nr; _i++) { \ + struct dive *mydive = get_dive(_i); \ if (!mydive) \ continue; \ if (!mydive->selected) \ -- cgit v1.2.3-70-g09d2