From c3d6bca80d24bff40f95d57b429c3cfb9f02b4b7 Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 29 Oct 2013 09:43:09 +0200 Subject: [PATCH] Fixed|Console|UI: Crash when using autocompletion The logic for reshowing the completion popup was incomplete. This commit fixes #1645. --- doomsday/client/src/ui/widgets/commandwidget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doomsday/client/src/ui/widgets/commandwidget.cpp b/doomsday/client/src/ui/widgets/commandwidget.cpp index 428c0d638f..6df9867c92 100644 --- a/doomsday/client/src/ui/widgets/commandwidget.cpp +++ b/doomsday/client/src/ui/widgets/commandwidget.cpp @@ -33,8 +33,9 @@ DENG_GUI_PIMPL(CommandWidget) shell::EditorHistory history; DocumentWidget *completions; PopupWidget *popup; ///< Popup for autocompletions. + bool allowReshow; ///< Contents must still be valid. - Instance(Public *i) : Base(i), history(i) + Instance(Public *i) : Base(i), history(i), allowReshow(false) { // Popup for autocompletions. completions = new DocumentWidget; @@ -89,7 +90,9 @@ bool CommandWidget::handleEvent(Event const &event) { KeyEvent const &key = event.as(); - if(isSuggestingCompletion() && key.qtKey() == Qt::Key_Tab && !d->popup->isOpen() && + if(d->allowReshow && + isSuggestingCompletion() && + key.qtKey() == Qt::Key_Tab && !d->popup->isOpen() && suggestedCompletions().size() > 1) { // The completion popup has been manually dismissed, but the editor is @@ -151,6 +154,7 @@ void CommandWidget::dismissContentToHistory() void CommandWidget::closeAutocompletionPopup() { d->popup->close(); + d->allowReshow = false; } void CommandWidget::showAutocompletionPopup(String const &completionsText) @@ -161,6 +165,8 @@ void CommandWidget::showAutocompletionPopup(String const &completionsText) d->popup->setAnchorX(cursorRect().middle().x); d->popup->setAnchorY(rule().top()); d->popup->open(); + + d->allowReshow = true; } void CommandWidget::autoCompletionEnded(bool accepted)