X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fguicast%2Fbcmenuitem.C;h=1e9399b1396c62ad55f3d08f0e3cad85c4a51f9a;hb=8a2d79c16c6793d7d3483e9a74205569228ca0cc;hp=2c4469e4cf6a9e0a90c6fb7c5ef54b0abd390453;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git 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)