]> git.vomp.tv Git - vompclient.git/commitdiff
Fix segfault pressing up in options
authorChris Tallon <chris@vomp.tv>
Mon, 28 Oct 2019 15:10:15 +0000 (15:10 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 28 Oct 2019 15:10:15 +0000 (15:10 +0000)
WOptionPane had no code for up when it was inactive
WTabBar now handles client refusing control

woptionpane.cc
wtabbar.cc

index fb5b456e0cd18bf8b339a92ac2a9536893c9a2f3..d2b053b09d82fc1a9a3b04f03cefdbaad3d28f06 100644 (file)
@@ -130,11 +130,17 @@ int WOptionPane::handleCommand(int command)
         optionBoxes[selectedOption]->setActive(1);
         return 1;
       }
-      else
+      else if (selectedOption == 0)
       {
         optionBoxes[selectedOption--]->setActive(0);
         return 4; // Signal return control to parent
       }
+      else if (selectedOption == -1) // Allow UP when inactive, start at the last optionBox
+      {
+        selectedOption = numOptions - 1;
+        optionBoxes[selectedOption]->setActive(1);
+        return 1;
+      }
     }
     case Remote::DF_DOWN:
     case Remote::DOWN:
index c161ce88f1967aef4220d7c1bd5a8246bf8153b0..dae739081dc0505d66d2553ada5f519622d67107 100644 (file)
@@ -163,16 +163,29 @@ int WTabBar::handleCommand(int command)
       case Remote::DOWN:
       case Remote::DF_DOWN:
       {
-        buttonBarActive = false;
-        tabs[visiblePane].button->dim();
-        symbolLeft.nextColour = DrawStyle::BUTTONBACKGROUND;
-        symbolRight.nextColour = DrawStyle::BUTTONBACKGROUND;
-        if (tabs[visiblePane].pane->handleCommand(command) == 1) // shouldn't return anything else at this point?!
+        int handleResult = tabs[visiblePane].pane->handleCommand(command);
+        // A WOptionPane will accept control being passed into it from inactive, up or down (== 1).
+        // A WTextBox will only accept control if it will scroll (== 1). It will refuse if not (== 4).
+
+        if (handleResult == 1)
         {
+          buttonBarActive = false;
+          tabs[visiblePane].button->dim();
+          symbolLeft.nextColour = DrawStyle::BUTTONBACKGROUND;
+          symbolRight.nextColour = DrawStyle::BUTTONBACKGROUND;
           draw();
           return 1;
         }
-      }    
+        else if (handleResult == 4)
+        {
+          // Do nothing.
+          return 2;
+        }
+        else
+        {
+          Log::getInstance()->log("WTabBar", Log::ERR, "Up/Down client returned not 1 or 4");
+        }
+      }
     }  
   }
   return 0;