diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2015-02-02 10:06:05 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2015-02-02 10:06:05 +0900 |
commit | d7398464a997bcb02e0900728365d74c5105d443 (patch) | |
tree | f993ba051c96eac4e5b61b64bf2def39c98dcd24 /tdefilereplace | |
parent | 23b906b576c51c02770bc9645c4b7291f5f3d6a7 (diff) | |
download | tdeutils-d7398464a997bcb02e0900728365d74c5105d443.tar.gz tdeutils-d7398464a997bcb02e0900728365d74c5105d443.zip |
TDEFileReplace: fixed unresponsive GUI and application crash when circular references are found on the file system.
Added a message to advice the user of the possible circular reference. This relates to bug 2264.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdefilereplace')
-rw-r--r-- | tdefilereplace/tdefilereplacepart.cpp | 40 | ||||
-rw-r--r-- | tdefilereplace/tdefilereplacepart.h | 5 |
2 files changed, 39 insertions, 6 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp index d4433b6..e3f1c42 100644 --- a/tdefilereplace/tdefilereplacepart.cpp +++ b/tdefilereplace/tdefilereplacepart.cpp @@ -52,6 +52,9 @@ #include "commandengine.h" #include "whatthis.h" +// Change this as well if increasing the max value allowed for the m_spbMaxDepth spinbox +static const int CIRCULAR_LINK_DETECTION_LEVEL = 256; + using namespace whatthisNameSpace; //PUBLIC CONSTRUCTORS @@ -71,6 +74,7 @@ TDEFileReplacePart::TDEFileReplacePart(TQWidget* parentWidget, const char* , TQO m_optionMask = TQDir::Files; m_w = widget(); m_option = 0; + m_circ_ref_warning_shown = false; loadOptionsFromRC(); initView(); @@ -130,7 +134,10 @@ void TDEFileReplacePart::slotSearchingOperation() uint filesNumber = 0; if(m_option->m_recursive) + { + m_circ_ref_warning_shown = false; recursiveFileSearch(currentDirectory, currentFilter, filesNumber, 0); + } else fileSearch(currentDirectory, currentFilter); @@ -196,6 +203,7 @@ void TDEFileReplacePart::slotReplacingOperation() if(m_option->m_recursive) { int filesNumber = 0; + m_circ_ref_warning_shown = false; recursiveFileReplace(currentDirectory, filesNumber, 0); } else @@ -972,6 +980,19 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int // if m_stop == true or the max depth level is reached, then interrupt recursion if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth)) return; + else if (!m_option->m_limitDepth && depth > CIRCULAR_LINK_DETECTION_LEVEL) + { + if (!m_circ_ref_warning_shown) + { + KMessageBox::information(m_w, + i18n("It seems you have a circular reference in your file system." + "The search has been limited to this sublevel to prevent" + "TDEFileReplace from crashing."), + i18n("Circular reference detected")); + m_circ_ref_warning_shown = true; + } + return; + } else { TQDir d(directoryName); @@ -985,7 +1006,6 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt) { - //if m_stop == true then end for-loop if(m_stop) break; @@ -1001,6 +1021,7 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int m_view->displayScannedFiles(filesNumber); + kapp->processEvents(); // Replace recursively if "filePath" is a directory and we have not reached the max depth level if (qi.isDir()) { @@ -1011,7 +1032,6 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int } else { - kapp->processEvents(); if(m_option->m_backup) replaceAndBackup(d.canonicalPath(), fileName); else @@ -1296,6 +1316,19 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons // if m_stop == true or the max depth level is reached, then interrupt recursion if (m_stop || (m_option->m_limitDepth && depth > m_option->m_maxDepth)) return; + else if (!m_option->m_limitDepth && depth > CIRCULAR_LINK_DETECTION_LEVEL) + { + if (!m_circ_ref_warning_shown) + { + KMessageBox::information(m_w, + i18n("It seems you have a circular reference in your file system. " + "The search has been limited to this sublevel to prevent " + "TDEFileReplace from crashing."), + i18n("Circular reference detected")); + m_circ_ref_warning_shown = true; + } + return; + } else { TQDir d(directoryName); @@ -1309,7 +1342,6 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons for(filesIt = filesList.begin(); filesIt != filesList.end(); ++filesIt) { - // stop polling if(m_stop) break; @@ -1323,6 +1355,7 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons m_view->displayScannedFiles(filesNumber); + kapp->processEvents(); // Searchs recursively if "filePath" is a directory and we have not reached the max depth level if (fileInfo.isDir()) { @@ -1333,7 +1366,6 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons } else { - kapp->processEvents(); search(filePath, fileName); filesNumber++; m_view->displayScannedFiles(filesNumber); diff --git a/tdefilereplace/tdefilereplacepart.h b/tdefilereplace/tdefilereplacepart.h index 579f7ab..34a91da 100644 --- a/tdefilereplace/tdefilereplacepart.h +++ b/tdefilereplace/tdefilereplacepart.h @@ -42,8 +42,9 @@ class TDEFileReplacePart: public KParts::ReadOnlyPart TDEAboutApplication* m_aboutDlg; KeyValueMap m_replacementMap; RCOptions* m_option; - bool m_stop, - m_searchingOperation; + bool m_stop; + bool m_searchingOperation; + bool m_circ_ref_warning_shown; int m_optionMask; public://Constructors |