mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-23 00:05:13 +03:00
[Simulator] Fix crash if error happens at startup before timer was created.
This commit is contained in:
parent
586567927a
commit
d90b1e0640
1 changed files with 19 additions and 17 deletions
|
@ -46,7 +46,7 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface *simulator
|
||||||
simulator(simulator),
|
simulator(simulator),
|
||||||
firmware(getCurrentFirmware()),
|
firmware(getCurrentFirmware()),
|
||||||
radioSettings(GeneralSettings()),
|
radioSettings(GeneralSettings()),
|
||||||
timer(NULL),
|
timer(new QTimer(this)),
|
||||||
radioUiWidget(NULL),
|
radioUiWidget(NULL),
|
||||||
vJoyLeft(NULL),
|
vJoyLeft(NULL),
|
||||||
vJoyRight(NULL),
|
vJoyRight(NULL),
|
||||||
|
@ -118,6 +118,10 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface *simulator
|
||||||
connect(vJoyRight, SIGNAL(trimButtonPressed(int)), this, SLOT(onTrimPressed(int)));
|
connect(vJoyRight, SIGNAL(trimButtonPressed(int)), this, SLOT(onTrimPressed(int)));
|
||||||
connect(vJoyRight, SIGNAL(trimButtonReleased()), this, SLOT(onTrimReleased()));
|
connect(vJoyRight, SIGNAL(trimButtonReleased()), this, SLOT(onTrimReleased()));
|
||||||
connect(vJoyRight, SIGNAL(trimSliderMoved(int,int)), this, SLOT(onTrimSliderMoved(int,int)));
|
connect(vJoyRight, SIGNAL(trimSliderMoved(int,int)), this, SLOT(onTrimSliderMoved(int,int)));
|
||||||
|
|
||||||
|
timer->setInterval(10);
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
||||||
|
connect(timer, SIGNAL(timeout()), radioUiWidget, SLOT(updateUi()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulatorWidget::~SimulatorWidget()
|
SimulatorWidget::~SimulatorWidget()
|
||||||
|
@ -443,11 +447,14 @@ void SimulatorWidget::start()
|
||||||
|
|
||||||
void SimulatorWidget::stop()
|
void SimulatorWidget::stop()
|
||||||
{
|
{
|
||||||
timer->stop();
|
if (timer)
|
||||||
simulator->stop();
|
timer->stop();
|
||||||
if (saveTempRadioData) {
|
if (simulator) {
|
||||||
startupData.fill(0, getEEpromSize(m_board));
|
simulator->stop();
|
||||||
simulator->readEepromData(startupData);
|
if (saveTempRadioData) {
|
||||||
|
startupData.fill(0, getEEpromSize(m_board));
|
||||||
|
simulator->readEepromData(startupData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,18 +636,13 @@ void SimulatorWidget::setupJoysticks()
|
||||||
|
|
||||||
void SimulatorWidget::setupTimer()
|
void SimulatorWidget::setupTimer()
|
||||||
{
|
{
|
||||||
if (timer) {
|
if (!timer)
|
||||||
timer->stop();
|
return;
|
||||||
disconnect(timer, 0, this, 0);
|
|
||||||
disconnect(timer, 0, radioUiWidget, 0);
|
|
||||||
timer->deleteLater();
|
|
||||||
timer = NULL;
|
|
||||||
}
|
|
||||||
timer = new QTimer(this);
|
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
|
||||||
connect(timer, SIGNAL(timeout()), radioUiWidget, SLOT(updateUi()));
|
|
||||||
|
|
||||||
timer->start(10);
|
if (timer->isActive())
|
||||||
|
timer->stop();
|
||||||
|
|
||||||
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorWidget::restoreRadioWidgetsState()
|
void SimulatorWidget::restoreRadioWidgetsState()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue