Fix QPixmap::scaled: Pixmap is a null pixmap error
This commit is contained in:
+2
-2
@@ -32,7 +32,7 @@ void ImageScrollArea::setImage(const QPixmap &img)
|
||||
|
||||
void ImageScrollArea::setScale(float scale)
|
||||
{
|
||||
if(scale > 4 || (scale < 0.2 && scale > 0))
|
||||
if(scale > 4 || (scale < 0.2 && scale > 0) || m_pixmap.isNull())
|
||||
return;
|
||||
|
||||
m_scale = scale;
|
||||
@@ -92,7 +92,7 @@ void ImageScrollArea::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void ImageScrollArea::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if(m_scale < 0)
|
||||
if(m_scale < 0 && !m_pixmap.isNull())
|
||||
{
|
||||
m_label->setPixmap(m_pixmap.scaled(event->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
m_label->resize(event->size());
|
||||
|
||||
Reference in New Issue
Block a user