Fix crash when spliting GLSL editor

Not a good idea to keep the editor stored since when removing
a split, for example, the editor will go away and the highlighter
is not aware of it anyhow since it actually belongs to the document.

Although it's not necessary for the fix this patch add another
constructor to SyntaxHighlighter which takes the BaseTextDocument.
This is convenient.

Task-number: QTCREATORBUG-5695
Change-Id: Ic91837b7d91ebd3a44c16e2fd589d7f6c5c0c002
Reviewed-on: http://codereview.qt.nokia.com/2508
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Leandro Melo
2011-08-02 12:26:00 +02:00
committed by Leandro T. C. Melo
parent ebb238c885
commit 3bf883997f
6 changed files with 20 additions and 10 deletions

View File

@@ -163,7 +163,7 @@ GLSLTextEditorWidget::GLSLTextEditorWidget(QWidget *parent) :
connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument()));
baseTextDocument()->setSyntaxHighlighter(new Highlighter(this, document()));
new Highlighter(baseTextDocument());
// if (m_modelManager) {
// m_semanticHighlighter->setModelManager(m_modelManager);
@@ -312,7 +312,7 @@ void GLSLTextEditorWidget::updateDocumentNow()
{
m_updateDocumentTimer->stop();
int variant = languageVariant();
int variant = languageVariant(mimeType());
const QString contents = toPlainText(); // get the code from the editor
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
@@ -371,10 +371,9 @@ void GLSLTextEditorWidget::updateDocumentNow()
}
}
int GLSLTextEditorWidget::languageVariant() const
int GLSLTextEditorWidget::languageVariant(const QString &type)
{
int variant = 0;
QString type = mimeType();
bool isVertex = false;
bool isFragment = false;
bool isDesktop = false;