ImageView null pixmap crash fix
This commit is contained in:
@@ -125,12 +125,15 @@ bool ImageView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
|
|
||||||
|
|
||||||
void ImageView::adjustView() {
|
void ImageView::adjustView() {
|
||||||
qreal mp = map.width() / map.size().boundedTo(size()).width();
|
int nw = map.size().boundedTo(size()).width();
|
||||||
if (mp > 1) {
|
if (nw > 0) {
|
||||||
item.setPixmap(map.scaled(map.size()/mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
qreal mp = map.width() / nw;
|
||||||
} else {
|
if (mp > 1.)
|
||||||
|
item.setPixmap(map.scaled(map.size() / mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
else
|
||||||
|
item.setPixmap(map);
|
||||||
|
} else
|
||||||
item.setPixmap(map);
|
item.setPixmap(map);
|
||||||
}
|
|
||||||
if (!autofit_) return;
|
if (!autofit_) return;
|
||||||
setSceneRect(item.boundingRect());
|
setSceneRect(item.boundingRect());
|
||||||
fitInView(&item, Qt::KeepAspectRatio);
|
fitInView(&item, Qt::KeepAspectRatio);
|
||||||
|
|||||||
Reference in New Issue
Block a user