Fix bad 'SoapySDR missing' modal dialog thread call

This commit is contained in:
Charles J. Cliffe 2016-01-13 21:59:47 -05:00
parent 416cb54fb9
commit 8d738aed25
4 changed files with 23 additions and 7 deletions

View File

@ -204,6 +204,7 @@ bool CubicSDR::OnInit() {
offset = 0;
ppm = 0;
devicesReady.store(false);
devicesFailed.store(false);
deviceSelectorOpen.store(false);
// Visual Data
@ -414,14 +415,12 @@ void CubicSDR::sdrEnumThreadNotify(SDREnumerator::SDREnumState state, std::strin
devs = SDREnumerator::enumerate_devices("", true);
devicesReady.store(true);
}
if (state == SDREnumerator::SDR_ENUM_FAILED) {
devicesFailed.store(true);
}
//if (appframe) { appframe->SetStatusText(message); }
notify_busy.unlock();
if (state == SDREnumerator::SDR_ENUM_FAILED) {
wxMessageDialog *info;
info = new wxMessageDialog(NULL, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
info->ShowModal();
}
}
@ -693,6 +692,10 @@ bool CubicSDR::areDevicesEnumerating() {
return !sdrEnum->isTerminated();
}
bool CubicSDR::areModulesMissing() {
return devicesFailed.load();
}
std::string CubicSDR::getNotification() {
std::string msg;
notify_busy.lock();

View File

@ -129,6 +129,7 @@ public:
bool areDevicesReady();
bool areDevicesEnumerating();
bool areModulesMissing();
std::string getNotification();
void addRemote(std::string remoteAddr);
@ -193,6 +194,7 @@ private:
std::thread *t_SDR, *t_SDREnum, *t_PostSDR, *t_SpectrumVisual, *t_DemodVisual;
std::atomic_bool devicesReady;
std::atomic_bool devicesFailed;
std::atomic_bool deviceSelectorOpen;
std::atomic_bool sampleRateInitialized;
std::atomic_bool useLocalMod;

View File

@ -7,6 +7,7 @@
SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent ) {
refresh = true;
failed = false;
m_addRemoteButton->Disable();
m_useSelectedButton->Disable();
m_deviceTimer.Start(250);
@ -229,6 +230,16 @@ void SDRDevicesDialog::OnTreeDoubleClick( wxMouseEvent& event ) {
void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
if (refresh) {
if (wxGetApp().areModulesMissing()) {
if (!failed) {
wxMessageDialog *info;
info = new wxMessageDialog(NULL, wxT("\nNo SoapySDR modules were found.\n\nCubicSDR requires at least one SoapySDR device support module to be installed.\n\nPlease visit https://github.com/cjcliffe/CubicSDR/wiki and in the build instructions for your platform read the 'Support Modules' section for more information."), wxT("\x28\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35\x20\u253B\u2501\u253B"), wxOK | wxICON_ERROR);
info->ShowModal();
failed = true;
}
return;
}
if (wxGetApp().areDevicesEnumerating() || !wxGetApp().areDevicesReady()) {
std::string msg = wxGetApp().getNotification();
devStatusBar->SetStatusText(msg);
@ -237,7 +248,7 @@ void SDRDevicesDialog::OnDeviceTimer( wxTimerEvent& event ) {
event.Skip();
return;
}
devTree->DeleteAllItems();
wxTreeItemId devRoot = devTree->AddRoot("Devices");

View File

@ -23,7 +23,7 @@ private:
SDRDeviceInfo *getSelectedDevice(wxTreeItemId selId);
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, SoapySDR::ArgInfo arg);
bool refresh;
bool refresh, failed;
std::map<std::string, std::vector<SDRDeviceInfo *>* > devs;
std::vector<SDRDeviceInfo *>::iterator devs_i;
std::map<wxTreeItemId, SDRDeviceInfo *> devItems;