Skip to content

Commit 4b07fc0

Browse files
committed
check edit enable fix
1 parent 5b6bf88 commit 4b07fc0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

QtCellLifeSimulationApp/GenerationSettingsWidget.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ void GenerationSettingsWidget::updateOptions()
6161
}
6262
}
6363

64+
bool GenerationSettingsWidget::checkEditEnable()
65+
{
66+
return checkEditEnable(editor_editid);
67+
}
68+
69+
bool GenerationSettingsWidget::checkEditEnable(int editid)
70+
{
71+
return factory != nullptr && editid >= 0 && editid < factory->getOptions().size();
72+
}
73+
6474
void GenerationSettingsWidget::generateColorSelectionEditorControls()
6575
{
6676
int index = 0;
@@ -240,7 +250,7 @@ void GenerationSettingsWidget::editor_editOptionByID(int editId)
240250

241251
void GenerationSettingsWidget::editor_setEditId(int editId)
242252
{
243-
editor_editid = editId;
253+
if (checkEditEnable(editId))editor_editid = editId;
244254
editor_updateStatusLabel();
245255
}
246256

@@ -303,7 +313,7 @@ void GenerationSettingsWidget::list_editSelectedOption()
303313
void GenerationSettingsWidget::editor_changemode()
304314
{
305315
if (!editor_editmode) {
306-
if (editor_editid < factory->getOptions().size()) {
316+
if (checkEditEnable()) {
307317
editor_setEditMode(!editor_editmode);
308318
editor_reset();
309319
}
@@ -315,6 +325,9 @@ void GenerationSettingsWidget::editor_changemode()
315325

316326
void GenerationSettingsWidget::editor_reset()
317327
{
328+
if (!checkEditEnable()) {
329+
editor_changemode();
330+
}
318331
if (editor_editmode) {
319332
editor_setParams(factory->getOptions()[editor_editid]);
320333
}

QtCellLifeSimulationApp/GenerationSettingsWidget.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class GenerationSettingsWidget : public QWidget
1818
private:
1919
void generateColorSelectionEditorControls();
2020
void updateOptions();
21+
bool checkEditEnable();
22+
bool checkEditEnable(int editid);
2123

2224
void selecter_setupGenerationAmont();
2325
void selecter_setOptionsList(std::vector<SimulationModel::Cells::CellFactory::GenerateOption> options);

0 commit comments

Comments
 (0)