Bug 138620 - Saving a picture destroy another picture
Summary: Saving a picture destroy another picture
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: ImageEditor-Save (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: VHI critical
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-10 12:21 UTC by Laurent COOPER
Modified: 2022-02-02 23:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.9.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent COOPER 2006-12-10 12:21:47 UTC
Version:           0.9.0-rc1 (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
OS:                Linux

Saving a picture can lead to destroy another picture.

If you open a picture A for editing with digikam editor, then you edit it. Then, you click in digikam main window on a B picture. 

The image editor component ask you "the picture was modified, do you want to save it".

But instead of asking " picture A was modified", it ask for the NEW picture.

If, as I did, you say yes, it overwrites picture B with the modified A picture, thus definitely destroying picture B. You then have the old A picture version, the new picture A version with B name, and picture B is utterly destroyed.

I think that an image manipulation program should not behave this way :)
Comment 1 Laurent COOPER 2006-12-10 12:34:39 UTC
Bug is more critical than first tought...

Edit picture A
Click on picture B
"do you want to save picture B?"
CANCEL (to avoid the bug)
then, having a look on editor, the picture is still named picture A.
Click on the save button
Normally, should be saved as A picture...
=> the picture is saved as B picture, B picture utterly destroyed!
Gasp :(
Comment 2 caulier.gilles 2006-12-10 14:17:13 UTC
Marcel, 

This file must be fixed before 0.9.0-final release

Gilles
Comment 3 Marcel Wiesweg 2006-12-10 16:00:11 UTC
SVN commit 612235 by mwiesweg:

Call promptUserSave _before_ changing variables, namely d->urlCurrent.

BUG: 138620


 M  +2 -1      NEWS  
 M  +16 -4     utilities/imageeditor/editor/imagewindow.cpp  


--- trunk/extragear/graphics/digikam/NEWS #612234:612235
@@ -368,6 +368,7 @@
 216 ==> 137770 : digiKam doesn't keep original unix rights when modifying comments/tags/rating.
 217 ==> 133091 : Changing date/time with numblock changes also the orientation.
 218 ==> 137993 : Importing photos into albums results in time/date file override with current one.
-219 ==> 
+219 ==> 138620 : Saving a picture destroy another picture
+220 ==> 
 
 ----------------------------------------------------------------------------------------------------
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.cpp #612234:612235
@@ -380,6 +380,9 @@
 void ImageWindow::loadURL(const KURL::List& urlList, const KURL& urlCurrent,
                           const QString& caption, bool allowSaving, AlbumIconView* view)
 {
+    if (!promptUserSave(d->urlCurrent))
+        return;
+
     d->urlList          = urlList;
     d->urlCurrent       = urlCurrent;
     d->imageInfoList    = ImageInfoList();
@@ -391,7 +394,19 @@
 void ImageWindow::loadImageInfos(const ImageInfoList &imageInfoList, ImageInfo *imageInfoCurrent,
                                  const QString& caption, bool allowSaving, AlbumIconView* view)
 {
-    // the ownership of the list's objects is passed to us
+    // The ownership of objects of imageInfoList is passed to us.
+    // imageInfoCurrent is contained in imageInfoList.
+
+    // Very first thing is to check for changes, user may choose to cancel operation
+    if (!promptUserSave(d->urlCurrent))
+    {
+        // delete objects from list
+        for (ImageInfoList::iterator it = imageInfoList.begin(); it != imageInfoList.end(); ++it)
+            delete *it;
+        return;
+    }
+
+    // take over ImageInfo list
     d->imageInfoList    = imageInfoList;
     d->imageInfoCurrent = imageInfoCurrent;
 
@@ -422,9 +437,6 @@
         KWin::deIconifyWindow(winId());
     }
 
-    if (!promptUserSave(d->urlCurrent))
-        return;
-
     setCaption(i18n("digiKam Image Editor - %1").arg(caption));
 
     d->view        = view;
Comment 4 Marcel Wiesweg 2006-12-22 15:16:14 UTC
*** Bug 139075 has been marked as a duplicate of this bug. ***