mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-09 10:17:58 -04:00
Update appframe menus from appframe instead of app thread..
- Possible fix for Linux menu update crash
This commit is contained in:
parent
7b48b4f69f
commit
4ffa518dcc
@ -416,7 +416,8 @@ AppFrame::AppFrame() :
|
|||||||
|
|
||||||
wxAcceleratorTable accel(3, entries);
|
wxAcceleratorTable accel(3, entries);
|
||||||
SetAcceleratorTable(accel);
|
SetAcceleratorTable(accel);
|
||||||
|
deviceChanged.store(false);
|
||||||
|
devInfo = NULL;
|
||||||
wxGetApp().deviceSelector();
|
wxGetApp().deviceSelector();
|
||||||
|
|
||||||
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
||||||
@ -430,10 +431,25 @@ AppFrame::~AppFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
|
void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
|
||||||
std::string deviceId = devInfo->getName();
|
this->devInfo = devInfo;
|
||||||
|
deviceChanged.store(true);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
void AppFrame::updateDeviceParams() {
|
||||||
|
|
||||||
|
if (!deviceChanged.load()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!devInfo) {
|
||||||
|
deviceChanged.store(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string deviceId = devInfo->getName();
|
||||||
|
|
||||||
|
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||||
|
|
||||||
int dsMode = devConfig->getDirectSampling();
|
int dsMode = devConfig->getDirectSampling();
|
||||||
|
|
||||||
if (dsMode > 0 && dsMode <= 2) {
|
if (dsMode > 0 && dsMode <= 2) {
|
||||||
@ -450,7 +466,7 @@ void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
|
|||||||
for (std::map<int, wxMenuItem *>::iterator i = sampleRateMenuItems.begin(); i != sampleRateMenuItems.end(); i++) {
|
for (std::map<int, wxMenuItem *>::iterator i = sampleRateMenuItems.begin(); i != sampleRateMenuItems.end(); i++) {
|
||||||
sampleRateMenu->Remove(i->first);
|
sampleRateMenu->Remove(i->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleRateMenuItems.erase(sampleRateMenuItems.begin(),sampleRateMenuItems.end());
|
sampleRateMenuItems.erase(sampleRateMenuItems.begin(),sampleRateMenuItems.end());
|
||||||
|
|
||||||
int ofs = 0;
|
int ofs = 0;
|
||||||
@ -470,7 +486,7 @@ void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
|
|||||||
if (!checked) {
|
if (!checked) {
|
||||||
sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->Check(true);
|
sampleRateMenuItems[wxID_BANDWIDTH_MANUAL]->Check(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wxGetApp().getAGCMode()) {
|
if (!wxGetApp().getAGCMode()) {
|
||||||
gainSpacerItem->Show(true);
|
gainSpacerItem->Show(true);
|
||||||
gainSizerItem->Show(true);
|
gainSizerItem->Show(true);
|
||||||
@ -486,6 +502,8 @@ void AppFrame::initDeviceParams(SDRDeviceInfo *devInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
agcMenuItem->Check(wxGetApp().getAGCMode());
|
agcMenuItem->Check(wxGetApp().getAGCMode());
|
||||||
|
|
||||||
|
deviceChanged.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -722,6 +740,10 @@ void AppFrame::OnThread(wxCommandEvent& event) {
|
|||||||
|
|
||||||
void AppFrame::OnIdle(wxIdleEvent& event) {
|
void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||||
|
|
||||||
|
if (deviceChanged.load()) {
|
||||||
|
updateDeviceParams();
|
||||||
|
}
|
||||||
|
|
||||||
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
if (demod) {
|
if (demod) {
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
void OnThread(wxCommandEvent& event);
|
void OnThread(wxCommandEvent& event);
|
||||||
void OnEventInput(wxThreadEvent& event);
|
void OnEventInput(wxThreadEvent& event);
|
||||||
void initDeviceParams(SDRDeviceInfo *devInfo);
|
void initDeviceParams(SDRDeviceInfo *devInfo);
|
||||||
|
void updateDeviceParams();
|
||||||
|
|
||||||
void saveSession(std::string fileName);
|
void saveSession(std::string fileName);
|
||||||
bool loadSession(std::string fileName);
|
bool loadSession(std::string fileName);
|
||||||
@ -110,6 +111,8 @@ private:
|
|||||||
FFTVisualDataThread *waterfallDataThread;
|
FFTVisualDataThread *waterfallDataThread;
|
||||||
|
|
||||||
std::thread *t_FFTData;
|
std::thread *t_FFTData;
|
||||||
|
SDRDeviceInfo *devInfo;
|
||||||
|
std::atomic_bool deviceChanged;
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user