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 github-actions committed Jul 21, 2021
1 parent be53a98 commit a282239f6e3a1d0cf0d220cd453950567ff25c32
@@ -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 a282239

Please sign in to comment.