Skip to content

Commit

Permalink
Avoid to manipulate m_texture via pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 5, 2024
1 parent a0a0ddb commit e5bdf9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/waveform/renderers/allshader/waveformrendererpreroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include "widget/wskincolor.h"

namespace {
void generateTexture(OpenGLTexture2D* pTexture,
float markerLength,
QImage drawPrerollImage(float markerLength,
float markerBreadth,
float devicePixelRatio,
QColor color) {
Expand Down Expand Up @@ -54,7 +53,7 @@ void generateTexture(OpenGLTexture2D* pTexture,
painter.drawPath(path);
painter.end();

pTexture->setData(image);
return image;
}
} // anonymous namespace

Expand Down Expand Up @@ -120,11 +119,10 @@ void WaveformRendererPreroll::paintGL() {
// has changed size last time.
m_markerLength = markerLength;
m_markerBreadth = markerBreadth;
generateTexture(&m_texture,
m_markerLength,
m_texture.setData(drawPrerollImage(m_markerLength,
m_markerBreadth,
m_waveformRenderer->getDevicePixelRatio(),
m_color);
m_color));
}

if (!m_texture.isStorageAllocated()) {
Expand Down
11 changes: 5 additions & 6 deletions src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

class TextureGraphics : public WaveformMark::Graphics {
public:
TextureGraphics() = default;

QOpenGLTexture* texture() {
TextureGraphics(const QImage& image) {
m_texture.setData(image);
}
QOpenGLTexture* texture() const {
return &m_texture;

Check failure on line 27 in src/waveform/renderers/allshader/waveformrendermark.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (gcc)

invalid conversion from ‘const QOpenGLTexture*’ to ‘QOpenGLTexture*’ [-fpermissive]

Check failure on line 27 in src/waveform/renderers/allshader/waveformrendermark.cpp

View workflow job for this annotation

GitHub Actions / coverage

invalid conversion from ‘const QOpenGLTexture*’ to ‘QOpenGLTexture*’ [-fpermissive]

Check failure on line 27 in src/waveform/renderers/allshader/waveformrendermark.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'return': cannot convert from 'const OpenGLTexture2D *' to 'QOpenGLTexture *'
}

Expand Down Expand Up @@ -321,8 +322,6 @@ void allshader::WaveformRenderMark::resizeGL(int, int) {
}

void allshader::WaveformRenderMark::updateMarkImage(WaveformMarkPointer pMark) {
auto pTextureGraphics = std::make_unique<TextureGraphics>();
pTextureGraphics->texture()->setData(
pMark->m_pGraphics = std::make_unique<TextureGraphics>(
pMark->generateImage(m_waveformRenderer->getDevicePixelRatio()));
pMark->m_pGraphics = std::move(pTextureGraphics);
}

0 comments on commit e5bdf9a

Please sign in to comment.