From c162f76815756781d4cc71ca9e0f439915c22b71 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 13 Nov 2015 12:43:16 +0100 Subject: [PATCH] [TASK] Restructure code for loading images. --- imageviewer-qt4.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index 7ea2c01..16cf53a 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -544,19 +544,17 @@ void ImageViewer::open() { delete image; image = NULL; } - + if(original_image!=NULL) { + delete original_image; + original_image = NULL; + } QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath()); if(!fileName.isEmpty()) { image = new QImage(fileName); + original_image = new QImage(fileName); if(image->isNull()) { QMessageBox::information(this, tr("Image Viewer"), tr("Cannot load %1.").arg(fileName)); return; - } else { - if(original_image!=NULL) { - delete original_image; - original_image = NULL; - } - original_image = new QImage(fileName); } scaleFactor = 1.0; updateImageDisplay();