Skip to content

Commit 57d163a

Browse files
committed
Fix: Broken behaviour for ascents without photos in viewer
1 parent 08987c6 commit 57d163a

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/viewer/ascent_viewer.cpp

+30-30
Original file line numberDiff line numberDiff line change
@@ -467,40 +467,40 @@ void AscentViewer::changeToPhoto(int photoIndex, bool saveDescriptionFirst)
467467

468468
if (currentPhotoIndex < 0 || photos.isEmpty()) {
469469
imageLabel->clearImage();
470-
return;
471-
}
472-
473-
QString filepath = photos.at(currentPhotoIndex).filepath;
474-
QImageReader reader(filepath);
475-
reader.setAutoTransform(true);
476-
const QImage newImage = reader.read();
477-
if (newImage.isNull()) {
478-
qDebug() << "Error reading" << filepath << reader.errorString();
479-
imageLabel->clearImage();
480-
481-
QString title = tr("File error");
482-
QString message = tr("Photo could not be loaded:")
483-
+ "\n" + filepath
484-
+ "\n\n" + tr("Do you want to remove it from this ascent?");
485-
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel;
486-
QMessageBox::StandardButton result = QMessageBox::warning(this, title, message, buttons);
487-
488-
if (result == QMessageBox::Yes) {
489-
removeCurrentPhoto(); // calls changeToPhoto() back, recursing until valid image is found or all photos removed
490-
}
491470
}
492471
else {
493-
image = newImage;
494-
if (image.colorSpace().isValid()) image.convertToColorSpace(QColorSpace::SRgb);
495-
imageLabel->setImage(image);
472+
QString filepath = photos.at(currentPhotoIndex).filepath;
473+
QImageReader reader = QImageReader(filepath);
474+
reader.setAutoTransform(true);
475+
const QImage newImage = reader.read();
476+
if (newImage.isNull()) {
477+
qDebug() << "Error reading" << filepath << reader.errorString();
478+
imageLabel->clearImage();
479+
480+
QString title = tr("File error");
481+
QString message = tr("Photo could not be loaded:")
482+
+ "\n" + filepath
483+
+ "\n\n" + tr("Do you want to remove it from this ascent?");
484+
QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel;
485+
QMessageBox::StandardButton result = QMessageBox::warning(this, title, message, buttons);
486+
487+
if (result == QMessageBox::Yes) {
488+
removeCurrentPhoto(); // calls changeToPhoto() back, recursing until valid image is found or all photos removed
489+
}
490+
}
491+
else {
492+
image = newImage;
493+
if (image.colorSpace().isValid()) image.convertToColorSpace(QColorSpace::SRgb);
494+
imageLabel->setImage(image);
495+
}
496+
497+
photoDescriptionLabel ->setText(photos.at(currentPhotoIndex).description);
498+
photoDescriptionLineEdit->setText(photos.at(currentPhotoIndex).description);
499+
photoDescriptionLabel ->setVisible(!photoDescriptionEditable);
500+
photoDescriptionLineEdit->setVisible(photoDescriptionEditable);
501+
imageLabel ->setToolTip(filepath);
496502
}
497503

498-
photoDescriptionLabel ->setText(photos.at(currentPhotoIndex).description);
499-
photoDescriptionLineEdit->setText(photos.at(currentPhotoIndex).description);
500-
photoDescriptionLabel ->setVisible(!photoDescriptionEditable);
501-
photoDescriptionLineEdit->setVisible(photoDescriptionEditable);
502-
imageLabel ->setToolTip(filepath);
503-
504504
updatePhotoIndexLabel();
505505
updatePhotoButtonsEnabled();
506506
}

0 commit comments

Comments
 (0)