Skip to content
Permalink
Browse files
[editor widgets] Avoid infinite image resize loop
  • Loading branch information
nirvn authored and nyalldawson committed Jun 21, 2021
1 parent d4cba80 commit cb5b54f83192fd4bf3ca2687d9ff723509883323
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 cb5b54f

Please sign in to comment.