Skip to content
Permalink
Browse files
[editor widgets] Avoid infinite image resize loop
  • Loading branch information
nirvn authored and nyalldawson committed May 31, 2021
1 parent 3532141 commit a8cad4a9b189d23b73aa602f0cfee3d9ff54c072
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/gui/qgspixmaplabel.cpp
@@ -32,8 +32,7 @@ void QgsPixmapLabel::setPixmap( const QPixmap &p )
updateGeometry();
}

QLabel::setPixmap( mPixmap.scaled( this->size(),
Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}

int QgsPixmapLabel::heightForWidth( int width ) const
@@ -58,7 +57,8 @@ void QgsPixmapLabel::resizeEvent( QResizeEvent *e )
QLabel::resizeEvent( e );
if ( !mPixmap.isNull() )
{
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
// Avoid infinite resize loop by setting a pixmap that'll always have a width and height less or equal to the label size
QLabel::setPixmap( mPixmap.scaled( this->size() -= QSize( 1, 1 ), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
}

0 comments on commit a8cad4a

Please sign in to comment.