Skip to content
Permalink
Browse files
Fix opacity slider crash
Fixes a race condition introduced by the timer.
  • Loading branch information
m-kuhn authored and nyalldawson committed Jul 21, 2021
1 parent 96f2cdb commit 15d419645d55e69e111a145d38b635d155ba7d2c
@@ -71,13 +71,17 @@ void QgsLayerTreeOpacityWidget::sliderValueChanged( int value )

void QgsLayerTreeOpacityWidget::updateOpacityFromSlider()
{
if ( !mLayer )
return;
int value = mSlider->value();
mLayer->setOpacity( value / 1000.0 );
mLayer->triggerRepaint();
}

void QgsLayerTreeOpacityWidget::layerTrChanged()
{
if ( !mLayer )
return;
mSlider->blockSignals( true );
mSlider->setValue( mLayer->opacity() * 1000.0 );
mSlider->blockSignals( false );
@@ -16,6 +16,7 @@
#ifndef QGSLAYERTREEEMBEDDEDWIDGETSIMPL_H
#define QGSLAYERTREEEMBEDDEDWIDGETSIMPL_H

#include <QPointer>
#include <QWidget>
#include "qgslayertreeembeddedwidgetregistry.h"

@@ -56,7 +57,7 @@ class QgsLayerTreeOpacityWidget : public QWidget
void layerTrChanged();

private:
QgsMapLayer *mLayer = nullptr;
QPointer<QgsMapLayer> mLayer;
QSlider *mSlider = nullptr;
QTimer *mTimer = nullptr;
};

0 comments on commit 15d4196

Please sign in to comment.