]> Git trees. - libqmvoc.git/commitdiff
Fix relative paths in saved kvtml documents
authorChristoph Feck <christoph@maxiom.de>
Tue, 21 May 2013 20:48:18 +0000 (22:48 +0200)
committerChristoph Feck <christoph@maxiom.de>
Tue, 21 May 2013 20:48:18 +0000 (22:48 +0200)
BUG: 318787
FIXED-IN: 4.10.4
REVIEW: 110432

keduvocdocument/keduvocdocument.cpp
keduvocdocument/keduvockvtml2writer.cpp

index 2ee65413de3b9ff585eff4d8d6b4ea8377c411c0..b73fc69e057937312cfd7912fbd6863531ac56f2 100644 (file)
@@ -379,7 +379,9 @@ int KEduVocDocument::saveAs( const KUrl & url, FileType ft, const QString & gene
         return FileCannotWrite;
     }
 
+    KUrl oldUrl = d->m_url;
     bool saved = false;
+    d->m_url = tmp;
 
     switch ( ft ) {
         case Kvtml: {
@@ -410,10 +412,10 @@ int KEduVocDocument::saveAs( const KUrl & url, FileType ft, const QString & gene
 
     if ( !saved ) {
         kError() << "Error Saving File" << tmp.path();
+        d->m_url = oldUrl;
         return FileWriterFailed;
     }
 
-    d->m_url = tmp;
     setModified( false );
     return 0;
 }
index 99ad94d8c9b963a06ada72c1241add54ff64ad93..859ab8b1cb704171d4764ca3d83ca9800ed88732 100644 (file)
@@ -531,7 +531,7 @@ bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEd
     // image
     if ( !translation->imageUrl().isEmpty() ) {
         QString urlString;
-        if ( translation->imageUrl().url().startsWith(m_doc->url().upUrl().url()) ) {
+        if ( m_doc->url().upUrl().isParentOf( translation->imageUrl()) ) {
             // try to save as relative url
             urlString = KUrl::relativeUrl( m_doc->url() , translation->imageUrl() );
         } else {
@@ -543,7 +543,7 @@ bool KEduVocKvtml2Writer::writeTranslation( QDomElement &translationElement, KEd
     // sound
     if ( !translation->soundUrl().isEmpty() ) {
         QString urlString;
-        if ( translation->soundUrl().url().startsWith(m_doc->url().upUrl().url()) ) {
+        if ( m_doc->url().upUrl().isParentOf( translation->soundUrl()) ) {
             // try to save as relative url
             urlString = KUrl::relativeUrl( m_doc->url() , translation->soundUrl() );
         } else {