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 bea6d91 commit 2239b022937b52bde0a41b2dbcf8ee75a4ff20c8
@@ -101,6 +101,8 @@ void QgsLayerTreeOpacityWidget::sliderValueChanged( int value )

void QgsLayerTreeOpacityWidget::updateOpacityFromSlider()
{
if ( !mLayer )
return;
int value = mSlider->value();

switch ( mLayer->type() )
@@ -128,6 +130,8 @@ void QgsLayerTreeOpacityWidget::updateOpacityFromSlider()

void QgsLayerTreeOpacityWidget::layerTrChanged()
{
if ( !mLayer )
return;
mSlider->blockSignals( true );
mSlider->setValue( qobject_cast<QgsVectorLayer *>( 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 2239b02

Please sign in to comment.