Fix a DemodulatorInstance dangling reference

This commit is contained in:
vsonnier 2017-08-29 06:40:07 +02:00
parent 03bf38fea8
commit dc9c67bec1
2 changed files with 5 additions and 4 deletions

View File

@ -60,7 +60,7 @@ std::vector<std::string> str_explode(const std::string &seperator, const std::st
#define APPFRAME_MODEMPROPS_MAXSIZE 240
AppFrame::AppFrame() :
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(nullptr) {
#ifdef __linux__
SetIcon(wxICON(cubicsdr));
@ -1734,7 +1734,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
wxGetApp().getDemodMgr().setLastBandwidth(demod->getBandwidth());
}
if (demod != activeDemodulator) {
if (demod.get() != activeDemodulator) {
demodSignalMeter->setInputValue(demod->getSquelchLevel());
demodGainMeter->setInputValue(demod->getGain());
wxGetApp().getDemodMgr().setLastGain(demod->getGain());
@ -1878,7 +1878,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demod->setGain(demodGainMeter->getInputValue());
demodGainMeter->setLevel(demodGainMeter->getInputValue());
}
activeDemodulator = demod;
activeDemodulator = demod.get();
} else if (demod) {
// Wait state for current demodulator modem to activate..
} else {

View File

@ -194,7 +194,8 @@ private:
wxBoxSizer *demodTray;
BookmarkView *bookmarkView;
DemodulatorInstancePtr activeDemodulator;
//Use a raw pointer here to prevent a dangling reference
DemodulatorInstance* activeDemodulator;
std::vector<RtAudio::DeviceInfo> devices;
std::map<int,RtAudio::DeviceInfo> inputDevices;