ImageView null pixmap crash fix

This commit is contained in:
2020-10-05 20:45:25 +03:00
parent 3245d71bc8
commit cb86646457

View File

@@ -125,12 +125,15 @@ bool ImageView::eventFilter(QObject * o, QEvent * e) {
void ImageView::adjustView() {
qreal mp = map.width() / map.size().boundedTo(size()).width();
if (mp > 1) {
item.setPixmap(map.scaled(map.size()/mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} else {
int nw = map.size().boundedTo(size()).width();
if (nw > 0) {
qreal mp = map.width() / nw;
if (mp > 1.)
item.setPixmap(map.scaled(map.size() / mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
else
item.setPixmap(map);
} else
item.setPixmap(map);
}
if (!autofit_) return;
setSceneRect(item.boundingRect());
fitInView(&item, Qt::KeepAspectRatio);