diff options
Diffstat (limited to 'src/gui.cpp')
| -rw-r--r-- | src/gui.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui.cpp b/src/gui.cpp index e800244..e3a8499 100644 --- a/src/gui.cpp +++ b/src/gui.cpp | |||
| @@ -1005,7 +1005,15 @@ static void DrawCreatePhraseDialog() | |||
| 1005 | ImGui::Checkbox("I have written these words down", &g_phraseWrittenDown); | 1005 | ImGui::Checkbox("I have written these words down", &g_phraseWrittenDown); |
| 1006 | ImGui::Spacing(); | 1006 | ImGui::Spacing(); |
| 1007 | 1007 | ||
| 1008 | if (!g_phraseWrittenDown) | 1008 | // Read the condition once, before the button that changes it. |
| 1009 | // | ||
| 1010 | // Pressing Finish clears g_phraseWrittenDown, so testing it again after | ||
| 1011 | // the click asked BeginDisabled and EndDisabled two different questions: | ||
| 1012 | // the pair was opened while the checkbox was ticked and closed after the | ||
| 1013 | // handler had unticked it. ImGui asserts on the unmatched EndDisabled -- | ||
| 1014 | // on the success path, so every phrase created from the window hit it. | ||
| 1015 | const bool fFinishDisabled = !g_phraseWrittenDown; | ||
| 1016 | if (fFinishDisabled) | ||
| 1009 | ImGui::BeginDisabled(); | 1017 | ImGui::BeginDisabled(); |
| 1010 | if (ImGui::Button("Finish", ImVec2(120.0f, 0.0f))) | 1018 | if (ImGui::Button("Finish", ImVec2(120.0f, 0.0f))) |
| 1011 | { | 1019 | { |
| @@ -1024,7 +1032,7 @@ static void DrawCreatePhraseDialog() | |||
| 1024 | g_showCreatePhrase = false; | 1032 | g_showCreatePhrase = false; |
| 1025 | g_needRefresh = true; | 1033 | g_needRefresh = true; |
| 1026 | } | 1034 | } |
| 1027 | if (!g_phraseWrittenDown) | 1035 | if (fFinishDisabled) |
| 1028 | ImGui::EndDisabled(); | 1036 | ImGui::EndDisabled(); |
| 1029 | 1037 | ||
| 1030 | ImGui::SameLine(); | 1038 | ImGui::SameLine(); |