Big fix and adding the removal of a picture if the user removes it from the
dive
if managed location is enabled.

-- 
Best regards,
Guido
From 62aa6f0a3f8333d0b4f6969fbecace1e50b23869 Mon Sep 17 00:00:00 2001
From: Guido Lerch <[email protected]>
Date: Tue, 13 Oct 2015 11:39:02 +0200
Subject: [PATCH 6/6] Image Management bug fix and image removal

Fixed an error with a declaration in qthelper.h

Added removal of a picture file from the managed location
if the user removes a picture.

Signed-off-by: Guido Lerch <[email protected]>
---
 dive.c       | 3 +++
 qthelper.cpp | 7 +++++++
 qthelper.h   | 1 -
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/dive.c b/dive.c
index 69b54c1..b77ac96 100644
--- a/dive.c
+++ b/dive.c
@@ -3370,6 +3370,9 @@ void dive_remove_picture(char *filename)
                struct picture *temp = (*picture)->next;
                picture_free(*picture);
                *picture = temp;
+               // if we have managed images, let's physically remove the file
+               if (prefs.manage_images)
+                       delete_file(filename);
        }
 }
 
diff --git a/qthelper.cpp b/qthelper.cpp
index 3480e8c..8feb09b 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -1603,3 +1603,10 @@ extern "C" bool dir_exists(char *dir)
        QDir d(dir);
        return d.exists();
 }
+
+extern "C" void delete_file(char *filename)
+{
+       QFile f(filename);
+       if (f.exists())
+               f.remove();
+}
diff --git a/qthelper.h b/qthelper.h
index 05c6973..f5457b1 100644
--- a/qthelper.h
+++ b/qthelper.h
@@ -130,6 +130,5 @@ bool parseGpsText(const QString &gps_text, double 
*latitude, double *longitude);
 QByteArray getCurrentAppState();
 void setCurrentAppState(QByteArray state);
 extern "C" bool in_planner();
-extern "C" bool dir_exists(char *dir);
 
 #endif // QTHELPER_H
-- 
2.3.8 (Apple Git-58)

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to