mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T311, avoid crash of model set dialog
- check for nullptr mapping component - disable new set button in dialog
This commit is contained in:
@@ -196,9 +196,10 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::enableButtons(bool firstSet)
|
||||
void CDbOwnModelSetComponent::enableButtons(bool firstSet, bool newSet)
|
||||
{
|
||||
ui->pb_FirstSet->setEnabled(firstSet);
|
||||
ui->pb_CreateNewSet->setEnabled(newSet);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::tabIndexChanged(int index)
|
||||
@@ -209,6 +210,8 @@ namespace BlackGui
|
||||
void CDbOwnModelSetComponent::buttonClicked()
|
||||
{
|
||||
const QObject *sender = QObject::sender();
|
||||
if (!sender) { return; }
|
||||
|
||||
if (sender == ui->pb_CreateNewSet)
|
||||
{
|
||||
this->createNewSet();
|
||||
@@ -312,15 +315,20 @@ namespace BlackGui
|
||||
// since we use the componet also in the launcher wizard, mc might not be existing
|
||||
const CSimulatorInfo simulator(this->getModelSetSimulator());
|
||||
CDbMappingComponent *mc = this->getMappingComponent();
|
||||
if (mc) { mc->setOwnModelsSimulator(simulator); }
|
||||
if (!mc)
|
||||
{
|
||||
CLogMessage(this).error("No mapping component available!");
|
||||
return;
|
||||
}
|
||||
|
||||
mc->setOwnModelsSimulator(simulator);
|
||||
if (!m_modelSetFormDialog)
|
||||
{
|
||||
m_modelSetFormDialog.reset(new CDbOwnModelSetFormDialog(this));
|
||||
m_modelSetFormDialog->setMappingComponent(this->getMappingComponent());
|
||||
}
|
||||
|
||||
if (this->getMappingComponent()->getOwnModelsCount() > 0)
|
||||
if (mc->getOwnModelsCount() > 0)
|
||||
{
|
||||
m_modelSetFormDialog->setModal(true);
|
||||
m_modelSetFormDialog->reloadData();
|
||||
@@ -333,7 +341,7 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << simulator.toQString(true);
|
||||
if (mc) { mc->showOverlayMessage(m); }
|
||||
mc->showOverlayMessage(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace BlackGui
|
||||
//! @}
|
||||
|
||||
//! Enable buttons
|
||||
void enableButtons(bool firstSet);
|
||||
void enableButtons(bool firstSet, bool newSet);
|
||||
|
||||
//! Set the model set for a given simulator
|
||||
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace BlackGui
|
||||
return ui->comp_OwnModelSet;
|
||||
}
|
||||
|
||||
void CDbOwnModelSetDialog::enableButtons(bool firstSet)
|
||||
void CDbOwnModelSetDialog::enableButtons(bool firstSet, bool newSet)
|
||||
{
|
||||
ui->comp_OwnModelSet->enableButtons(firstSet);
|
||||
ui->comp_OwnModelSet->enableButtons(firstSet, newSet);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace BlackGui
|
||||
CDbOwnModelSetComponent *modelSetComponent();
|
||||
|
||||
//! Enable buttons
|
||||
void enableButtons(bool firstSet);
|
||||
void enableButtons(bool firstSet, bool newSet);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbOwnModelSetDialog> ui;
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace BlackGui
|
||||
{
|
||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||
m_modelSetDialog->setSimulator(simulator);
|
||||
m_modelSetDialog->enableButtons(false);
|
||||
m_modelSetDialog->enableButtons(false, false);
|
||||
m_modelSetDialog->exec();
|
||||
|
||||
// force UI update
|
||||
|
||||
Reference in New Issue
Block a user