diff --git a/src/plugins/glsleditor/GLSLEditor.mimetypes.xml b/src/plugins/glsleditor/GLSLEditor.mimetypes.xml index d9fa822b01e..5d63307c03d 100644 --- a/src/plugins/glsleditor/GLSLEditor.mimetypes.xml +++ b/src/plugins/glsleditor/GLSLEditor.mimetypes.xml @@ -1,14 +1,26 @@ + - GLSL file + GLSL Shader file + + + + + GLSL Fragment Shader file - + + + + + GLSL Fragment Shader file + + diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index 7d8fcc51ae3..bd782cca0be 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -276,8 +276,10 @@ void GLSLTextEditor::updateDocumentNow() Semantic sem; Scope *globalScope = engine.newNamespace(); sem.translationUnit(plugin->shaderInit()->ast, globalScope, plugin->shaderInit()->engine); - sem.translationUnit(plugin->vertexShaderInit()->ast, globalScope, plugin->vertexShaderInit()->engine); - sem.translationUnit(plugin->fragmentShaderInit()->ast, globalScope, plugin->fragmentShaderInit()->engine); + if (isVertexShader()) + sem.translationUnit(plugin->vertexShaderInit()->ast, globalScope, plugin->vertexShaderInit()->engine); + if (isFragmentShader()) + sem.translationUnit(plugin->fragmentShaderInit()->ast, globalScope, plugin->fragmentShaderInit()->engine); sem.translationUnit(ast, globalScope, &engine); QTextCharFormat errorFormat; @@ -314,3 +316,13 @@ void GLSLTextEditor::updateDocumentNow() // refresh the identifiers. m_identifiers = engine.identifiers(); } + +bool GLSLTextEditor::isVertexShader() const +{ + return mimeType() == QLatin1String("text/x-glsl-vert"); +} + +bool GLSLTextEditor::isFragmentShader() const +{ + return mimeType() == QLatin1String("text/x-glsl-frag"); +} diff --git a/src/plugins/glsleditor/glsleditor.h b/src/plugins/glsleditor/glsleditor.h index f1847802eee..9f126199bb0 100644 --- a/src/plugins/glsleditor/glsleditor.h +++ b/src/plugins/glsleditor/glsleditor.h @@ -65,6 +65,9 @@ public: QSet identifiers() const; + bool isVertexShader() const; + bool isFragmentShader() const; + public slots: virtual void setFontSettings(const TextEditor::FontSettings &);