From 6e440ebc11fc12e2c9721a399d0ed97501aaa40b Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 30 Jan 2014 05:46:48 +0100 Subject: [PATCH] CMenuForwarder: Fix options handling Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/08130328a021d9b804f3201d8699e5aa7dc5439e Author: Michael Liebmann Date: 2014-01-30 (Thu, 30 Jan 2014) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp | 35 +++++++++++++++++++++++++---------- src/gui/widget/menue.h | 5 +++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index a86fc473c..a3581c486 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1814,7 +1814,8 @@ int CMenuOptionLanguageChooser::paint( bool selected ) //------------------------------------------------------------------------------------------------------------------------------- CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option_string_ptr = &Option; + option_string = &Option; + option = NULL; name = Text; nameString = ""; active = Active; @@ -1828,7 +1829,8 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option_string_ptr = &Option; + option_string = &Option; + option = NULL; name = NONEXISTANT_LOCALE; nameString = Text; active = Active; @@ -1842,8 +1844,8 @@ CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option_string = Option ? Option : ""; - option_string_ptr = &option_string; + option_string = NULL; + option = Option; name = Text; nameString = ""; active = Active; @@ -1857,8 +1859,8 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option_string = Option ? Option : ""; - option_string_ptr = &option_string; + option_string = NULL; + option = Option; name = NONEXISTANT_LOCALE; nameString = Text; active = Active; @@ -1882,9 +1884,20 @@ void CMenuForwarder::setName(const neutrino_locale_t t) nameString = ""; } +void CMenuForwarder::setOption(const char * const Option) +{ + option = Option; + option_string = NULL; + if (used && x != -1) + paint(); +} + void CMenuForwarder::setOption(const std::string &Option) { - option_string = Option; + option = NULL; + option_string = &Option; + if (used && x != -1) + paint(); } int CMenuForwarder::getHeight(void) const @@ -1924,9 +1937,11 @@ int CMenuForwarder::exec(CMenuTarget* parent) std::string CMenuForwarder::getOption(void) { - if (!option_string_ptr->empty()) - return *option_string_ptr; - if (jumpTarget) + if (option) + return (std::string)option; + else if (option_string) + return *option_string; + else if (jumpTarget) return jumpTarget->getValue(); return ""; } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index c6e9c234e..c66484fea 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -217,8 +217,8 @@ class CMenuForwarder : public CMenuItem std::string actionKey; protected: - std::string option_string; - const std::string * option_string_ptr; + const char * option; + const std::string * option_string; CMenuTarget * jumpTarget; virtual std::string getOption(void); @@ -250,6 +250,7 @@ class CMenuForwarder : public CMenuItem int exec(CMenuTarget* parent); bool isSelectable(void) const { return active; } void setOption(const std::string &Option); + void setOption(const char * const Option); void setName(const std::string& text); void setName(const neutrino_locale_t text); };