Skip to content
Permalink
Browse files
Merge pull request #44304 from qgis/backport-44290-to-release-3_16
[Backport release-3_16] Fix opacity slider crash
  • Loading branch information
rouault committed Jul 21, 2021
2 parents bea6d91 + 2239b02 commit 4311770ccaad7bb8a3f24748327c2d571f7af6fe
@@ -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 4311770

Please sign in to comment.