Bug 131728 - using 'save as' on an existing open file causes file difference message at next save
Summary: using 'save as' on an existing open file causes file difference message at ne...
Status: RESOLVED FIXED
Alias: None
Product: quanta
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: András Manţia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-02 14:26 UTC by Remco
Modified: 2006-09-04 10:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remco 2006-08-02 14:26:17 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I've found multiple bugreports on this one, but where all either resolved in an earlier version (than KDE 3.5.2), or somehow different in nature.

When:
- opening an existing file
- saving as with a different name
- then editing and saving

A messagebox pops up and says the file was externally modified.

It looks like the loaded file is compared to the file with the previous filename.


Thanks,
Remco
Comment 1 András Manţia 2006-09-01 23:38:36 UTC
SVN commit 579876 by amantia:

Save As asked for confirmation of "save before close" for modified files due to the setEncoding() call. This was confusing and could result in data loss as well. For now, remove the possibility to change the encoding in the save dialog (users should change the encoding and save later or save and change later).

Possiby fixes #131728  (I cannot reproduce it with this version).

BUG: 131728 

 M  +1 -0      ChangeLog  
 M  +14 -7     src/quanta.cpp  


--- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #579875:579876
@@ -4,6 +4,7 @@
  - bugfixes:
       - do not allow growing of quantarc until it crashes Quanta [#111049]
       - symlink handling fixes (hopefully won't break anything)
+      - fix Save As problems, possibly #131728
 
 Version 3.5.4 (Release date: 02-08-2006; Started 24-06-2005):
  - bugfixes:
--- branches/KDE/3.5/kdewebdev/quanta/src/quanta.cpp #579875:579876
@@ -376,7 +376,7 @@
     if (!QExtFileInfo::exists(*i, true, this))
     {
       KMessageBox::error(this, i18n("<qt>The file <b>%1</b> does not exist or is not a recognized mime type.</qt>").arg((*i).prettyURL(0, KURL::StripFileProtocol)));
-      
+
     } else
     {
       if (QuantaCommon::checkMimeGroup(*i, "text") ||
@@ -463,8 +463,10 @@
       fileWatcher->removeFile(oldURL.path());
 //      kdDebug(24000) << "removeFile[slotFileSaveAs]: " << oldURL.path() << endl;
     }
-    QString myEncoding =  dynamic_cast<KTextEditor::EncodingInterface*>(w->doc())->encoding();
 
+    //FIXME: in katepart changing encoding saves the original file if it was modified, so it's useless in saveas...
+//    QString myEncoding =  dynamic_cast<KTextEditor::EncodingInterface*>(w->doc())->encoding();
+
     bool gotPath = false;
 
     KURL saveAsUrl;
@@ -502,15 +504,20 @@
         saveAsUrl.setPath(saveAsUrl.directory(false, false) + oldURL.fileName());
       }
 
-
+//FIXME: in katepart changing encoding saves the original file if it was modified, so it's useless in saveas...
+      /*
     KEncodingFileDialog::Result data;
     data = KEncodingFileDialog::getSaveURLAndEncoding(myEncoding, saveAsUrl.url(),
         "all/allfiles text/html text/xml application/x-php text/plain", this, i18n("Save File"));
     KURL saveUrl = data.URLs[0];
-    QString encoding = data.encoding;
+    bool found;
+    QString encoding = KGlobal::charsets()->codecForName(data.encoding, found)->name();
     KTextEditor::EncodingInterface* encodingIf = dynamic_cast<KTextEditor::EncodingInterface*>(w->doc());
-    if (encodingIf)
+    if (encodingIf && encodingIf->encoding() != encoding)
        encodingIf->setEncoding(encoding);
+      */
+    KURL saveUrl = KFileDialog::getSaveURL(saveAsUrl.url(),
+         "all/allfiles text/html text/xml application/x-php text/plain", this, i18n("Save File"));
 
     if (QuantaCommon::checkOverwrite(saveUrl, this) && view->saveDocument(saveUrl))
     {
@@ -3419,7 +3426,7 @@
 //FIXME: Find a good way to redraw the editor view when the toolbar height
 //changes
 //  if (ViewManager::ref()->activeView())
-    //ViewManager::ref()->activeView()->activated();  
+    //ViewManager::ref()->activeView()->activated();
 }
 
 
@@ -4486,7 +4493,7 @@
     delete dlg;
 
   } else
-  if (!node || w->currentDTD(true)->name == "text/css") 
+  if (!node || w->currentDTD(true)->name == "text/css")
   {
         kdDebug(24000) << "[CSS editor] This is a pure CSS document" << endl;
 
Comment 2 Remco 2006-09-04 08:41:43 UTC
I never change encoding when saving as, but still this bug occurs. 
Comment 3 András Manţia 2006-09-04 10:32:43 UTC
Yes, but this is a bug in Katepart which I workarounded for 3.5.5.