Skip to content

Commit

Permalink
Fixed|Console|UI: Crash when using autocompletion
Browse files Browse the repository at this point in the history
The logic for reshowing the completion popup was incomplete.

This commit fixes #1645.
  • Loading branch information
skyjake committed Oct 29, 2013
1 parent eb233f4 commit c3d6bca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doomsday/client/src/ui/widgets/commandwidget.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -89,7 +90,9 @@ bool CommandWidget::handleEvent(Event const &event)
{
KeyEvent const &key = event.as<KeyEvent>();

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
Expand Down Expand Up @@ -151,6 +154,7 @@ void CommandWidget::dismissContentToHistory()
void CommandWidget::closeAutocompletionPopup()
{
d->popup->close();
d->allowReshow = false;
}

void CommandWidget::showAutocompletionPopup(String const &completionsText)
Expand All @@ -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)
Expand Down

0 comments on commit c3d6bca

Please sign in to comment.