mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-21 15:25:12 +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),
|
||||
firmware(getCurrentFirmware()),
|
||||
radioSettings(GeneralSettings()),
|
||||
timer(NULL),
|
||||
timer(new QTimer(this)),
|
||||
radioUiWidget(NULL),
|
||||
vJoyLeft(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(trimButtonReleased()), this, SLOT(onTrimReleased()));
|
||||
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()
|
||||
|
@ -443,13 +447,16 @@ void SimulatorWidget::start()
|
|||
|
||||
void SimulatorWidget::stop()
|
||||
{
|
||||
if (timer)
|
||||
timer->stop();
|
||||
if (simulator) {
|
||||
simulator->stop();
|
||||
if (saveTempRadioData) {
|
||||
startupData.fill(0, getEEpromSize(m_board));
|
||||
simulator->readEepromData(startupData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorWidget::restart()
|
||||
{
|
||||
|
@ -629,18 +636,13 @@ void SimulatorWidget::setupJoysticks()
|
|||
|
||||
void SimulatorWidget::setupTimer()
|
||||
{
|
||||
if (timer) {
|
||||
timer->stop();
|
||||
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()));
|
||||
if (!timer)
|
||||
return;
|
||||
|
||||
timer->start(10);
|
||||
if (timer->isActive())
|
||||
timer->stop();
|
||||
|
||||
timer->start();
|
||||
}
|
||||
|
||||
void SimulatorWidget::restoreRadioWidgetsState()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue