GLSL: Do not leak engine

Change-Id: I756361cc2aa4ad7bd91acde23dc0267520c6490c
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2015-01-13 14:26:33 +01:00
parent 3945243e86
commit 41d1c7e0e1

View File

@@ -213,13 +213,13 @@ void GlslEditorWidget::updateDocumentNow()
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor. const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
Document::Ptr doc(new Document()); Document::Ptr doc(new Document());
Engine *engine = new GLSL::Engine(); Engine engine;
doc->_engine = new GLSL::Engine(); doc->_engine = new GLSL::Engine();
Parser parser(doc->_engine, preprocessedCode.constData(), preprocessedCode.size(), variant); Parser parser(doc->_engine, preprocessedCode.constData(), preprocessedCode.size(), variant);
TranslationUnitAST *ast = parser.parse(); TranslationUnitAST *ast = parser.parse();
if (ast != 0 || extraSelections(CodeWarningsSelection).isEmpty()) { if (ast != 0 || extraSelections(CodeWarningsSelection).isEmpty()) {
Semantic sem; Semantic sem;
Scope *globalScope = engine->newNamespace(); Scope *globalScope = engine.newNamespace();
doc->_globalScope = globalScope; doc->_globalScope = globalScope;
const GlslEditorPlugin::InitFile *file = GlslEditorPlugin::shaderInit(variant); const GlslEditorPlugin::InitFile *file = GlslEditorPlugin::shaderInit(variant);
sem.translationUnit(file->ast, globalScope, file->engine); sem.translationUnit(file->ast, globalScope, file->engine);
@@ -231,7 +231,7 @@ void GlslEditorWidget::updateDocumentNow()
file = GlslEditorPlugin::fragmentShaderInit(variant); file = GlslEditorPlugin::fragmentShaderInit(variant);
sem.translationUnit(file->ast, globalScope, file->engine); sem.translationUnit(file->ast, globalScope, file->engine);
} }
sem.translationUnit(ast, globalScope, engine); sem.translationUnit(ast, globalScope, &engine);
CreateRanges createRanges(document(), doc); CreateRanges createRanges(document(), doc);
createRanges(ast); createRanges(ast);
@@ -247,7 +247,7 @@ void GlslEditorWidget::updateDocumentNow()
QList<QTextEdit::ExtraSelection> sels; QList<QTextEdit::ExtraSelection> sels;
QSet<int> errors; QSet<int> errors;
foreach (const DiagnosticMessage &m, engine->diagnosticMessages()) { foreach (const DiagnosticMessage &m, engine.diagnosticMessages()) {
if (! m.line()) if (! m.line())
continue; continue;
else if (errors.contains(m.line())) else if (errors.contains(m.line()))