From 0d928543d89a69e0141242dbecbcbeff7641b937 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 2 Nov 2015 21:04:02 -0500 Subject: [PATCH] Fix for ubuntu menu update crash --- src/AppFrame.cpp | 25 ++++++++++++------------- src/AppFrame.h | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index b4d16b6..9ad2e25 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -236,7 +236,7 @@ AppFrame::AppFrame() : // SetIcon(wxICON(sample)); // Make a menubar - wxMenuBar *menuBar = new wxMenuBar; + menuBar = new wxMenuBar; wxMenu *menu = new wxMenu; menu->Append(wxID_SDR_DEVICES, "SDR Devices"); @@ -316,9 +316,6 @@ AppFrame::AppFrame() : menuBar->Append(menu, wxT("&Color Scheme")); - sampleRateMenu = new wxMenu; - menuBar->Append(sampleRateMenu, wxT("&Input Bandwidth")); - menu = new wxMenu; #define NUM_RATES_DEFAULT 4 @@ -367,6 +364,10 @@ AppFrame::AppFrame() : } } + sampleRateMenu = new wxMenu; + + menuBar->Append(sampleRateMenu, wxT("&Input Bandwidth")); + menuBar->Append(menu, wxT("Audio &Bandwidth")); SetMenuBar(menuBar); @@ -462,18 +463,14 @@ void AppFrame::updateDeviceParams() { // Build sample rate menu from device info sampleRates = devInfo->getRxChannel()->getSampleRates(); - - for (std::map::iterator i = sampleRateMenuItems.begin(); i != sampleRateMenuItems.end(); i++) { - sampleRateMenu->Remove(i->first); - } - sampleRateMenuItems.erase(sampleRateMenuItems.begin(),sampleRateMenuItems.end()); + wxMenu *newSampleRateMenu = new wxMenu; int ofs = 0; long sampleRate = wxGetApp().getSampleRate(); bool checked = false; for (vector::iterator i = sampleRates.begin(); i != sampleRates.end(); i++) { - sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs] = sampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_BASE+ofs, frequencyToStr(*i)); + sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs] = newSampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_BASE+ofs, frequencyToStr(*i)); if (sampleRate == (*i)) { sampleRateMenuItems[wxID_BANDWIDTH_BASE+ofs]->Check(true); checked = true; @@ -481,12 +478,14 @@ void AppFrame::updateDeviceParams() { ofs++; } - sampleRateMenuItems[wxID_BANDWIDTH_MANUAL] = sampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_MANUAL, "Manual Entry"); - + sampleRateMenuItems[wxID_BANDWIDTH_MANUAL] = newSampleRateMenu->AppendRadioItem(wxID_BANDWIDTH_MANUAL, wxT("Manual Entry")); if (!checked) { sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->Check(true); } - + + menuBar->Replace(4, newSampleRateMenu, wxT("&Input Bandwidth")); + sampleRateMenu = newSampleRateMenu; + if (!wxGetApp().getAGCMode()) { gainSpacerItem->Show(true); gainSizerItem->Show(true); diff --git a/src/AppFrame.h b/src/AppFrame.h index b15108c..f3baa88 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -101,6 +101,7 @@ private: std::map sampleRateMenuItems; std::map audioSampleRateMenuItems; std::map directSamplingMenuItems; + wxMenuBar *menuBar; wxMenuItem *iqSwapMenuItem; wxMenu *sampleRateMenu; wxMenuItem *agcMenuItem;