Fixed index out of range.

Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
Robert Loehning
2009-11-02 19:14:40 +01:00
parent 674c2635b6
commit e68753b48b
3 changed files with 9 additions and 1 deletions

View File

@@ -131,6 +131,11 @@ int BackwardsScanner::previousBlockState(const QTextBlock &block) const
return 0;
}
int BackwardsScanner::size() const
{
return _tokens.size();
}
int BackwardsScanner::startOfMatchingBrace(int index) const
{
const BackwardsScanner &tk = *this;

View File

@@ -69,6 +69,8 @@ public:
int previousBlockState(const QTextBlock &block) const;
int size() const;
private:
const SimpleToken &fetchToken(int i);

View File

@@ -1579,7 +1579,8 @@ void CPPEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedCha
tabSettings().indentLine(block, indent);
return;
} else if ((firstToken.is(T_PUBLIC) || firstToken.is(T_PROTECTED) || firstToken.is(T_PRIVATE) ||
firstToken.is(T_Q_SIGNALS) || firstToken.is(T_Q_SLOTS)) && tk[1].is(T_COLON)) {
firstToken.is(T_Q_SIGNALS) || firstToken.is(T_Q_SLOTS)) &&
tk.size() > 1 && tk[1].is(T_COLON)) {
const int startOfBlock = tk.startOfBlock(0);
if (startOfBlock != 0) {
const int indent = tk.indentation(startOfBlock);