Fix crash when pressing Enter key in formspec menu
authorKahrl <kahrl@gmx.net>
Fri, 22 Nov 2013 23:30:16 +0000 (00:30 +0100)
committerKahrl <kahrl@gmx.net>
Fri, 22 Nov 2013 23:37:32 +0000 (00:37 +0100)
src/guiFormSpecMenu.cpp

index 2416e4c8aa0c589cf856f8d187df369ffe61c38d..8ffddcbc60c705145693d3bf5a2037a122a822ab 100644 (file)
@@ -2297,12 +2297,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
 
                        switch (event.KeyInput.Key) {
                                case KEY_RETURN:
-                                       if (m_allowclose) {
-                                               acceptInput(true);
-                                               quitMenu();
-                                       }
-                                       else
-                                               current_keys_pending.key_enter = true;
+                                       current_keys_pending.key_enter = true;
                                        break;
                                case KEY_UP:
                                        current_keys_pending.key_up = true;
@@ -2316,7 +2311,13 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
                                        assert("reached a source line that can't ever been reached" == 0);
                                        break;
                        }
-                       acceptInput();
+                       if (current_keys_pending.key_enter && m_allowclose) {
+                               acceptInput(true);
+                               quitMenu();
+                       }
+                       else {
+                               acceptInput();
+                       }
                        return true;
                }