Sophie

Sophie

distrib > Mandriva > 2008.0 > x86_64 > media > main-backports-src > by-pkgid > 8461b141ab7a2161b7518163d04e37da > files > 3

digikam-0.9.3-6mdv2008.0.src.rpm

Index: utilities/imageeditor/editor/editorwindow.cpp
===================================================================
--- utilities/imageeditor/editor/editorwindow.cpp	(revision 726776)
+++ utilities/imageeditor/editor/editorwindow.cpp	(working copy)
@@ -1653,8 +1653,16 @@
 {
     QCString dstFileName = QFile::encodeName(m_savingContext->destinationURL.path());
 
-    // store old permissions
-    mode_t filePermissions = S_IREAD | S_IWRITE;
+    // Store old permissions:
+    // Just get the current umask.
+    mode_t curr_umask = umask(S_IREAD | S_IWRITE);
+    // Restore the umask.
+    umask(curr_umask);
+
+    // For new files respect the umask setting.
+    mode_t filePermissions = (S_IREAD | S_IWRITE | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP) & ~curr_umask;
+    
+    // For existing files, use the mode of the original file.
     if (m_savingContext->destinationExisted)
     {
         struct stat stbuf;
@@ -1673,12 +1681,9 @@
     }
 
     // restore permissions
-    if (m_savingContext->destinationExisted)
+    if (::chmod(dstFileName, filePermissions) != 0)
     {
-        if (::chmod(dstFileName, filePermissions) != 0)
-        {
-            DWarning() << "Failed to restore file permissions for file " << dstFileName << endl;
-        }
+        DWarning() << "Failed to restore file permissions for file " << dstFileName << endl;
     }
 
     return true;