Skip to content
Permalink
Browse files
Merge pull request #44303 from qgis/backport-44290-to-release-3_20
[Backport release-3_20] Fix opacity slider crash
  • Loading branch information
rouault committed Jul 21, 2021
2 parents be53a98 + a282239 commit ac2884af789a108494848052ba96acd849874d7d
@@ -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 ac2884a

Please sign in to comment.