waveformscope: fixed double free on close

This commit is contained in:
itsmattkc
2020-04-28 17:40:22 +10:00
parent 737edba243
commit ad419754a9
3 changed files with 18 additions and 5 deletions
+14 -5
View File
@@ -33,6 +33,15 @@ WaveformScope::WaveformScope(QWidget* parent) :
EnableDefaultContextMenu();
}
WaveformScope::~WaveformScope()
{
CleanUp();
if (context()) {
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp);
}
}
void WaveformScope::SetBuffer(Frame *frame)
{
buffer_ = frame;
@@ -54,9 +63,7 @@ void WaveformScope::initializeGL()
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp, Qt::DirectConnection);
if (buffer_) {
UploadTextureFromBuffer();
}
UploadTextureFromBuffer();
}
void WaveformScope::paintGL()
@@ -86,6 +93,10 @@ void WaveformScope::paintGL()
void WaveformScope::UploadTextureFromBuffer()
{
if (!buffer_) {
return;
}
makeCurrent();
if (!texture_.IsCreated()
@@ -105,8 +116,6 @@ void WaveformScope::UploadTextureFromBuffer()
void WaveformScope::CleanUp()
{
qDebug() << "Cleaned up...";
makeCurrent();
pipeline_ = nullptr;