From cd3904660187e6ed16fca2911549bc7af155aea5 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 28 Oct 2019 15:10:15 +0000 Subject: [PATCH] Fix segfault pressing up in options WOptionPane had no code for up when it was inactive WTabBar now handles client refusing control --- woptionpane.cc | 8 +++++++- wtabbar.cc | 25 +++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/woptionpane.cc b/woptionpane.cc index fb5b456..d2b053b 100644 --- a/woptionpane.cc +++ b/woptionpane.cc @@ -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: diff --git a/wtabbar.cc b/wtabbar.cc index c161ce8..dae7390 100644 --- a/wtabbar.cc +++ b/wtabbar.cc @@ -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; -- 2.39.2