]> git.mxchange.org Git - flightgear.git/commitdiff
Fix some off-by-one errors in variants GUI
authorJames Turner <zakalawe@mac.com>
Thu, 5 Mar 2015 14:51:33 +0000 (14:51 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 5 Mar 2015 14:51:33 +0000 (14:51 +0000)
src/GUI/QtLauncher.cxx

index 71c83fe403a163957a4cafd79c5a0b6ee54a9f26..5775a442d4d5eddf3e569db64fc298f32eee38da 100644 (file)
@@ -293,9 +293,9 @@ public:
 
         quint32 variantIndex = m_activeVariant.at(index.row());
         if (variantIndex) {
-            if (variantIndex < item->variants.count()) {
+            if (variantIndex <= item->variants.count()) {
                 // show the selected variant
-                item = item->variants.at(variantIndex);
+                item = item->variants.at(variantIndex - 1);
             }
         }
 
@@ -424,7 +424,7 @@ public:
 
         if (variantCount > 0) {
             bool canLeft = (currentVariant > 0);
-            bool canRight =  (currentVariant < (variantCount - 1));
+            bool canRight =  (currentVariant < variantCount );
 
             QRect leftArrowRect = leftCycleArrowRect(option.rect, index);
             painter->fillRect(leftArrowRect, canLeft ? Qt::black : Qt::gray);
@@ -486,7 +486,7 @@ public:
                     m_view->model()->setData(index, variantIndex - 1, AircraftVariantRole);
                     emit variantChanged(index);
                     return true;
-                } else if ((variantIndex < (variantCount - 1)) && rightCycleRect.contains(me->pos())) {
+                } else if ((variantIndex < variantCount) && rightCycleRect.contains(me->pos())) {
                     m_view->model()->setData(index, variantIndex + 1, AircraftVariantRole);
                     emit variantChanged(index);
                     return true;