X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcmenuitem.C;fp=cinelerra-5.1%2Fguicast%2Fbcmenuitem.C;h=1e9399b1396c62ad55f3d08f0e3cad85c4a51f9a;hp=2c4469e4cf6a9e0a90c6fb7c5ef54b0abd390453;hb=e41864cf7931bfb86f68c5d35d4578dfe161d386;hpb=537b18f6fd34e3499123fb25287cd35b28efc491 diff --git a/cinelerra-5.1/guicast/bcmenuitem.C b/cinelerra-5.1/guicast/bcmenuitem.C index 2c4469e4..1e9399b1 100644 --- a/cinelerra-5.1/guicast/bcmenuitem.C +++ b/cinelerra-5.1/guicast/bcmenuitem.C @@ -29,6 +29,7 @@ #include "bcsignals.h" #include "bcwindowbase.h" #include "bccolors.h" +#include "cstrdup.h" #include @@ -44,6 +45,8 @@ BC_MenuItem::BC_MenuItem(const char *text, const char *hotkey_text, int hotkey) { + this->text = 0; + this->hotkey_text = 0; reset(); if(text) set_text(text); @@ -74,10 +77,8 @@ BC_MenuItem::~BC_MenuItem() void BC_MenuItem::reset() { - text = new char[1]; - hotkey_text = new char[1]; - text[0] = 0; - hotkey_text[0] = 0; + set_text(""); + set_hotkey_text(""); icon = 0; } @@ -112,16 +113,14 @@ BC_Pixmap* BC_MenuItem::get_icon() void BC_MenuItem::set_text(const char *text) { - if(this->text) delete [] this->text; - this->text = new char[strlen(text) + 1]; - strcpy(this->text, text); + delete [] this->text; + this->text = cstrdup(text); } void BC_MenuItem::set_hotkey_text(const char *text) { - if(this->hotkey_text) delete [] this->hotkey_text; - this->hotkey_text = new char[strlen(text) + 1]; - strcpy(this->hotkey_text, text); + delete [] this->hotkey_text; + this->hotkey_text = cstrdup(text); } int BC_MenuItem::deactivate_submenus(BC_MenuPopup *exclude)