diff --git a/effects/effect.cpp b/effects/effect.cpp index 77ae3b223..68d082300 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -123,7 +123,8 @@ Effect::Effect(Clip* c, const EffectMeta *em) : bound(false), iterations(1), enabled_(true), - expanded_(true) + expanded_(true), + texture_ctx(nullptr) { if (em != nullptr) { // set up UI from effect file @@ -881,7 +882,7 @@ void Effect::process_shader(double timecode, GLTextureCoords&, int iteration) { void Effect::process_coords(double, GLTextureCoords&, int) {} -GLuint Effect::process_superimpose(double timecode) { +GLuint Effect::process_superimpose(QOpenGLContext* ctx, double timecode) { bool dimensions_changed = false; bool redrew_image = false; @@ -898,7 +899,7 @@ GLuint Effect::process_superimpose(double timecode) { redrew_image = true; } - QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions(); + QOpenGLFunctions* f = ctx->functions(); if (texture == 0 || tex_width_ != img.width() || tex_height_ != img.height()) { delete_texture(); @@ -1109,8 +1110,11 @@ bool Effect::valueHasChanged(double timecode) { } void Effect::delete_texture() { - QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &texture); - texture = 0; + if (texture_ctx != nullptr) { + texture_ctx->functions()->glDeleteTextures(1, &texture); + texture = 0; + texture_ctx = nullptr; + } } const EffectMeta* get_meta_from_name(const QString& input) { diff --git a/effects/effect.h b/effects/effect.h index 71d456589..9fbc462f8 100644 --- a/effects/effect.h +++ b/effects/effect.h @@ -191,7 +191,7 @@ public: virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); virtual void process_shader(double timecode, GLTextureCoords&, int iteration); virtual void process_coords(double timecode, GLTextureCoords& coords, int data); - virtual GLuint process_superimpose(double timecode); + virtual GLuint process_superimpose(QOpenGLContext *ctx, double timecode); virtual void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count); virtual void gizmo_draw(double timecode, GLTextureCoords& coords); @@ -231,6 +231,7 @@ protected: // superimpose effect QImage img; GLuint texture; + QOpenGLContext* texture_ctx; int tex_width_; int tex_height_; diff --git a/rendering/renderfunctions.cpp b/rendering/renderfunctions.cpp index fc6c242d1..27aedecec 100644 --- a/rendering/renderfunctions.cpp +++ b/rendering/renderfunctions.cpp @@ -284,7 +284,7 @@ void process_effect(QOpenGLContext* ctx, } } if (e->Flags() & Effect::SuperimposeFlag) { - GLuint superimpose_texture = e->process_superimpose(timecode); + GLuint superimpose_texture = e->process_superimpose(ctx, timecode); if (superimpose_texture == 0) { qWarning() << "Superimpose texture was nullptr, retrying...";