diff options
author | Liang Qi <liang.qi@qt.io> | 2019-10-04 15:27:15 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-10-04 15:27:15 +0200 |
commit | 96a20440093aff70e78d01d6f014630bda5b0713 (patch) | |
tree | b9e6b6da88b8a0b909d3fa51ac0d191c61efc2ce /examples | |
parent | 3598ffcc26dbae14d88c32fabfc8be465eed8f61 (diff) | |
parent | a3790681a58ff0ff5f3a7dd53c473013a792e949 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/network/access/qnetworkaccessmanager.cpp
src/network/access/qnetworkreplyhttpimpl.cpp
Change-Id: I059be651604623616fd31e8616be8ae61b4f8883
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gui/openglwindow/main.cpp | 25 | ||||
-rw-r--r-- | examples/widgets/graphicsview/flowlayout/flowlayout.cpp | 2 |
2 files changed, 15 insertions, 12 deletions
diff --git a/examples/gui/openglwindow/main.cpp b/examples/gui/openglwindow/main.cpp index d1e5d3871e..03a6ece06f 100644 --- a/examples/gui/openglwindow/main.cpp +++ b/examples/gui/openglwindow/main.cpp @@ -67,9 +67,9 @@ public: void render() override; private: - GLuint m_posAttr = 0; - GLuint m_colAttr = 0; - GLuint m_matrixUniform = 0; + GLint m_posAttr = 0; + GLint m_colAttr = 0; + GLint m_matrixUniform = 0; QOpenGLShaderProgram *m_program = nullptr; int m_frame = 0; @@ -122,8 +122,11 @@ void TriangleWindow::initialize() m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource); m_program->link(); m_posAttr = m_program->attributeLocation("posAttr"); + Q_ASSERT(m_posAttr != -1); m_colAttr = m_program->attributeLocation("colAttr"); + Q_ASSERT(m_colAttr != -1); m_matrixUniform = m_program->uniformLocation("matrix"); + Q_ASSERT(m_matrixUniform != -1); } //! [4] @@ -144,13 +147,13 @@ void TriangleWindow::render() m_program->setUniformValue(m_matrixUniform, matrix); - GLfloat vertices[] = { - 0.0f, 0.707f, + static const GLfloat vertices[] = { + 0.0f, 0.707f, -0.5f, -0.5f, - 0.5f, -0.5f + 0.5f, -0.5f }; - GLfloat colors[] = { + static const GLfloat colors[] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f @@ -159,13 +162,13 @@ void TriangleWindow::render() glVertexAttribPointer(m_posAttr, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, colors); - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); + glEnableVertexAttribArray(m_posAttr); + glEnableVertexAttribArray(m_colAttr); glDrawArrays(GL_TRIANGLES, 0, 3); - glDisableVertexAttribArray(1); - glDisableVertexAttribArray(0); + glDisableVertexAttribArray(m_colAttr); + glDisableVertexAttribArray(m_posAttr); m_program->release(); diff --git a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp b/examples/widgets/graphicsview/flowlayout/flowlayout.cpp index 54914b3746..03cf320568 100644 --- a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp +++ b/examples/widgets/graphicsview/flowlayout/flowlayout.cpp @@ -62,7 +62,7 @@ FlowLayout::FlowLayout(QGraphicsLayoutItem *parent) : QGraphicsLayout(parent) void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item) { item->setParentLayoutItem(this); - if (index > m_items.count()) + if (index > m_items.count() || index < 0) index = m_items.count(); m_items.insert(index, item); invalidate(); |