[TASK] Restructure code for loading images.
This commit is contained in:
parent
5c1e651179
commit
c162f76815
|
@ -544,19 +544,17 @@ void ImageViewer::open() {
|
||||||
delete image;
|
delete image;
|
||||||
image = NULL;
|
image = NULL;
|
||||||
}
|
}
|
||||||
|
if(original_image!=NULL) {
|
||||||
|
delete original_image;
|
||||||
|
original_image = NULL;
|
||||||
|
}
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath());
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath());
|
||||||
if(!fileName.isEmpty()) {
|
if(!fileName.isEmpty()) {
|
||||||
image = new QImage(fileName);
|
image = new QImage(fileName);
|
||||||
|
original_image = new QImage(fileName);
|
||||||
if(image->isNull()) {
|
if(image->isNull()) {
|
||||||
QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(fileName));
|
QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(fileName));
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
if(original_image!=NULL) {
|
|
||||||
delete original_image;
|
|
||||||
original_image = NULL;
|
|
||||||
}
|
|
||||||
original_image = new QImage(fileName);
|
|
||||||
}
|
}
|
||||||
scaleFactor = 1.0;
|
scaleFactor = 1.0;
|
||||||
updateImageDisplay();
|
updateImageDisplay();
|
||||||
|
|
Loading…
Reference in New Issue