Only bind wxEVT_COMMAND_MENU_SELECTED once rather than once per command as large numbers of event handlers make wx explode

Originally committed to SVN as r5263.
This commit is contained in:
Thomas Goyne 2011-01-23 06:45:03 +00:00
parent 88be46c657
commit 10c3a2ca16
1 changed files with 3 additions and 5 deletions

View File

@ -151,10 +151,7 @@ FrameMain::FrameMain (wxArrayString args)
StartupLog("Binding commands");
// XXX: This is a hack for now, it will need to be dealt with when other frames are involved.
int count = cmd::count();
for (int i = 0; i < count; i++) {
Bind(wxEVT_COMMAND_MENU_SELECTED, &FrameMain::cmd_call, this, i);
}
Bind(wxEVT_COMMAND_MENU_SELECTED, &FrameMain::cmd_call, this);
#ifdef __WXMAC__
// Bind(FrameMain::OnAbout, &FrameMain::cmd_call, this, cmd::id("app/about"));
@ -242,7 +239,8 @@ FrameMain::~FrameMain () {
void FrameMain::cmd_call(wxCommandEvent& event) {
int id = event.GetId();
LOG_D("event/select") << "Id: " << id;
cmd::call(context.get(), id);
if (id < cmd::count())
cmd::call(context.get(), id);
}
/// @brief Initialize toolbar