diff --git a/Implementation/GUI/imageviewer.cpp b/Implementation/GUI/imageviewer.cpp
index 02cf132aeda44bd540288a0117981dbcd442f8e0..b1749addef001036b6b037bf9758c777754d6689 100644
--- a/Implementation/GUI/imageviewer.cpp
+++ b/Implementation/GUI/imageviewer.cpp
@@ -551,6 +551,8 @@ void ImageViewer::calculateVisible(){
     }
     pixmap=px;
     setImage(px->toImage());
+    painter->end();
+    delete px;
 }
 void ImageViewer::makeShaped(){
     if(hasLayer){
diff --git a/Implementation/build-imageviewer-Desktop-Release/imageviewer.o b/Implementation/build-imageviewer-Desktop-Release/imageviewer.o
index 07088ef52c3ab1fe1cdadfcd72c73a97626e790e..7d3a45b3e9e99355098b924e803cf5cfe1140ba5 100644
Binary files a/Implementation/build-imageviewer-Desktop-Release/imageviewer.o and b/Implementation/build-imageviewer-Desktop-Release/imageviewer.o differ