Fix potential bugs with Find in Files
- Iteration still going on after scan finished - Comparing milliseconds with seconds - Potential imprecision due to accumulating milliseconds (iteration could take fewer than 1ms) - Folders to scan not cleared when a new search starts
This commit is contained in:
parent
0fa3e30263
commit
6f6ee60e19
1 changed files with 6 additions and 4 deletions
|
@ -109,6 +109,7 @@ void FindInFiles::start() {
|
||||||
_current_dir = "";
|
_current_dir = "";
|
||||||
PoolStringArray init_folder;
|
PoolStringArray init_folder;
|
||||||
init_folder.append(_root_dir);
|
init_folder.append(_root_dir);
|
||||||
|
_folders_stack.clear();
|
||||||
_folders_stack.push_back(init_folder);
|
_folders_stack.push_back(init_folder);
|
||||||
|
|
||||||
_initial_files_count = 0;
|
_initial_files_count = 0;
|
||||||
|
@ -127,11 +128,12 @@ void FindInFiles::_process() {
|
||||||
// This part can be moved to a thread if needed
|
// This part can be moved to a thread if needed
|
||||||
|
|
||||||
OS &os = *OS::get_singleton();
|
OS &os = *OS::get_singleton();
|
||||||
float duration = 0.0;
|
float time_before = os.get_ticks_msec();
|
||||||
while (duration < 1.0 / 120.0) {
|
while (is_processing()) {
|
||||||
float time_before = os.get_ticks_msec();
|
|
||||||
_iterate();
|
_iterate();
|
||||||
duration += (os.get_ticks_msec() - time_before);
|
float elapsed = (os.get_ticks_msec() - time_before);
|
||||||
|
if (elapsed > 1000.0 / 120.0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue