[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/kio/kio
From:       David Faure <faure () kde ! org>
Date:       2008-08-11 8:05:32
Message-ID: 1218441932.978088.6420.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 845064 by dfaure:

Fix crash when skipping a source URL in the direct-renaming phase (#157601)


 M  +17 -8     copyjob.cpp  


--- branches/KDE/4.1/kdelibs/kio/kio/copyjob.cpp #845063:845064
@@ -151,6 +151,7 @@
     QList<CopyInfo> dirs;
     KUrl::List dirsToRemove;
     KUrl::List m_srcList;
+    KUrl::List m_skippedSourceUrls;
     KUrl::List::const_iterator m_currentStatSrc;
     bool m_bCurrentSrcIsDir;
     bool m_bCurrentOperationIsLink;
@@ -768,8 +769,8 @@
 {
     // If this is one if toplevel sources,
     // remove it from d->m_srcList, for a correct FilesRemoved() signal
-    //kDebug(7007) << "looking for " << sourceUrl;
-    m_srcList.removeAll( sourceUrl );
+    // But don't do it right away, we have iterators into that list (#157601)
+    m_skippedSourceUrls.append( sourceUrl );
     dirsToRemove.removeAll( sourceUrl );
 }
 
@@ -809,7 +810,7 @@
             // Should we skip automatically ?
             if ( m_bAutoSkip ) {
                 // We don't want to copy files in this directory, so we put it on the skip list
-              m_skipList.append( oldURL.path( KUrl::AddTrailingSlash ) );
+                m_skipList.append( oldURL.path( KUrl::AddTrailingSlash ) );
                 skip( oldURL );
                 dirs.erase( it ); // Move on to next dir
             } else {
@@ -1513,6 +1514,9 @@
             //kDebug(7007) << "KDirNotify'ing FilesAdded " << url;
             org::kde::KDirNotify::emitFilesAdded( url.url() );
 
+            Q_FOREACH(const KUrl& url, m_skippedSourceUrls)
+                m_srcList.removeAll(url);
+
             if ( m_mode == CopyJob::Move && !m_srcList.isEmpty() ) {
                 //kDebug(7007) << "KDirNotify'ing FilesRemoved " << m_srcList.toStringList();
                 org::kde::KDirNotify::emitFilesRemoved( m_srcList.toStringList() );
@@ -1657,10 +1661,9 @@
         Q_ASSERT( m_currentSrcURL == *m_currentStatSrc );
 
         // Existing dest?
-        if ( ( err == ERR_DIR_ALREADY_EXIST ||
-               err == ERR_FILE_ALREADY_EXIST ||
-               err == ERR_IDENTICAL_FILES )
-             && q->isInteractive() )
+        if ( err == ERR_DIR_ALREADY_EXIST ||
+             err == ERR_FILE_ALREADY_EXIST ||
+             err == ERR_IDENTICAL_FILES )
         {
             if (m_reportTimer)
                 m_reportTimer->stop();
@@ -1672,7 +1675,7 @@
                 return;
             } else if ( m_bOverwriteAll ) {
                 ; // nothing to do, stat+copy+del will overwrite
-            } else {
+            } else if ( q->isInteractive() ) {
                 QString newPath;
                 // If src==dest, use "overwrite-itself"
                 RenameDialog_Mode mode = (RenameDialog_Mode)
@@ -1761,6 +1764,12 @@
                     //assert( 0 );
                     break;
                 }
+            } else if ( err != KIO::ERR_UNSUPPORTED_ACTION ) {
+                // Dest already exists, and job is not interactive -> abort with error
+                q->setError( err );
+                q->setErrorText( errText );
+                q->emitResult();
+                return;
             }
         } else if ( err != KIO::ERR_UNSUPPORTED_ACTION ) {
             kDebug(7007) << "Couldn't rename" << m_currentSrcURL << "to" << dest << ", aborting";
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic