Commit c3b6d150 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by hjk

C++: Add some QTC_ASSERT guards in CodeAssistPrivate

This should prevent a not reproducible crash.

Change-Id: I8ebdec02799e1eccd37e918d5ab02a0a7fa5afac
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 7b705839
......@@ -41,6 +41,7 @@
#include <texteditor/texteditorsettings.h>
#include <texteditor/completionsettings.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <QObject>
#include <QList>
......@@ -221,7 +222,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
AssistKind kind,
IAssistProvider *provider)
{
Q_ASSERT(!isWaitingForProposal());
QTC_ASSERT(!isWaitingForProposal(), return);
if (!provider) {
if (kind == Completion) {
......@@ -328,6 +329,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
void CodeAssistantPrivate::processProposalItem(IAssistProposalItem *proposalItem)
{
QTC_ASSERT(m_proposal, return);
proposalItem->apply(m_textEditor, m_proposal->basePosition());
destroyContext();
process();
......@@ -335,6 +337,7 @@ void CodeAssistantPrivate::processProposalItem(IAssistProposalItem *proposalItem
void CodeAssistantPrivate::handlePrefixExpansion(const QString &newPrefix)
{
QTC_ASSERT(m_proposal, return);
const int currentPosition = m_textEditor->position();
m_textEditor->setCursorPosition(m_proposal->basePosition());
m_textEditor->replace(currentPosition - m_proposal->basePosition(), newPrefix);
......@@ -397,6 +400,7 @@ void CodeAssistantPrivate::notifyChange()
stopAutomaticProposalTimer();
if (isDisplayingProposal()) {
QTC_ASSERT(m_proposal, return);
if (m_textEditor->position() < m_proposal->basePosition()) {
destroyContext();
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment