CMenuForwarder: Use std::string (not pointer to std::string or char) for option

This commit is contained in:
Michael Liebmann
2013-07-04 01:08:21 +02:00
parent d313392144
commit b5d1322617
2 changed files with 10 additions and 20 deletions

View File

@@ -1598,8 +1598,7 @@ int CMenuOptionLanguageChooser::paint( bool selected )
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
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) 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)
{ {
option = Option; option = (Option != NULL) ? (std::string)Option : "";
option_string = NULL;
text=Text; text=Text;
active = Active; active = Active;
jumpTarget = Target; jumpTarget = Target;
@@ -1611,8 +1610,7 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active,
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) 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)
{ {
option = NULL; option = Option;
option_string = &Option;
text=Text; text=Text;
active = Active; active = Active;
jumpTarget = Target; jumpTarget = Target;
@@ -1652,10 +1650,8 @@ int CMenuForwarder::getWidth(void)
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(text), true); int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(text), true);
const char * option_text = NULL; const char * option_text = NULL;
if (option) if (!option.empty())
option_text = option; option_text = option.c_str();
else if (option_string)
option_text = option_string->c_str();
if (option_text != NULL) if (option_text != NULL)
@@ -1678,11 +1674,8 @@ int CMenuForwarder::exec(CMenuTarget* parent)
const char * CMenuForwarder::getOption(void) const char * CMenuForwarder::getOption(void)
{ {
if (option) if (!option.empty())
return option; return option.c_str();
else
if (option_string)
return option_string->c_str();
else else
return NULL; return NULL;
} }
@@ -1756,10 +1749,8 @@ int CMenuForwarderNonLocalized::getWidth(void)
{ {
int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(the_text, true); int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(the_text, true);
const char * option_text = NULL; const char * option_text = NULL;
if (option) if (!option.empty())
option_text = option; option_text = option.c_str();
else if (option_string)
option_text = option_string->c_str();
if (option_text != NULL) if (option_text != NULL)
tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true);

View File

@@ -198,8 +198,7 @@ class CMenuForwarder : public CMenuItem
std::string actionKey; std::string actionKey;
protected: protected:
const char * option; std::string option;
const std::string * option_string;
CMenuTarget * jumpTarget; CMenuTarget * jumpTarget;
neutrino_locale_t text; neutrino_locale_t text;