File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
6474void GenerationSettingsWidget::generateColorSelectionEditorControls ()
6575{
6676 int index = 0 ;
@@ -240,7 +250,7 @@ void GenerationSettingsWidget::editor_editOptionByID(int editId)
240250
241251void 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()
303313void 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
316326void GenerationSettingsWidget::editor_reset ()
317327{
328+ if (!checkEditEnable ()) {
329+ editor_changemode ();
330+ }
318331 if (editor_editmode) {
319332 editor_setParams (factory->getOptions ()[editor_editid]);
320333 }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class GenerationSettingsWidget : public QWidget
1818private:
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);
You can’t perform that action at this time.
0 commit comments