summaryrefslogtreecommitdiffstats
path: root/tdefilereplace/tdefilereplacepart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdefilereplace/tdefilereplacepart.cpp')
-rw-r--r--tdefilereplace/tdefilereplacepart.cpp48
1 files changed, 41 insertions, 7 deletions
diff --git a/tdefilereplace/tdefilereplacepart.cpp b/tdefilereplace/tdefilereplacepart.cpp
index e0bb9f97..e91fa462 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)
- recursiveFileSearch(currentDirectory, currentFilter, filesNumber);
+ {
+ m_circ_ref_warning_shown = false;
+ recursiveFileSearch(currentDirectory, currentFilter, filesNumber, 0);
+ }
else
fileSearch(currentDirectory, currentFilter);
@@ -196,7 +203,8 @@ void TDEFileReplacePart::slotReplacingOperation()
if(m_option->m_recursive)
{
int filesNumber = 0;
- recursiveFileReplace(currentDirectory, filesNumber);
+ m_circ_ref_warning_shown = false;
+ recursiveFileReplace(currentDirectory, filesNumber, 0);
}
else
{
@@ -962,11 +970,24 @@ void TDEFileReplacePart::fileReplace()
}
}
-void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber)
+void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int& filesNumber, int depth)
{
//if m_stop == true then interrupts recursion
if(m_stop)
return;
+ else if (!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);
@@ -995,13 +1016,13 @@ void TDEFileReplacePart::recursiveFileReplace(const TQString& directoryName, int
TQFileInfo qi(filePath);
m_view->displayScannedFiles(filesNumber);
+ kapp->processEvents();
//if filePath is a directory then recursion
if(qi.isDir())
- recursiveFileReplace(filePath, filesNumber);
+ recursiveFileReplace(filePath, filesNumber, depth+1);
else
{
- kapp->processEvents();
if(m_option->m_backup)
replaceAndBackup(d.canonicalPath(), fileName);
else
@@ -1285,6 +1306,19 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
// if m_stop == true then interrupt recursion
if(m_stop)
return;
+ else if (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);
@@ -1312,12 +1346,12 @@ void TDEFileReplacePart::recursiveFileSearch(const TQString& directoryName, cons
m_view->displayScannedFiles(filesNumber);
+ kapp->processEvents();
// Searchs recursively if "filePath" is a directory
if(fileInfo.isDir())
- recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber);
+ recursiveFileSearch(filePath+"/"+fileName, filters, filesNumber, depth+1);
else
{
- kapp->processEvents();
search(filePath, fileName);
filesNumber++;
m_view->displayScannedFiles(filesNumber);