mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:47:45 +00:00
Assistant: Fix crash in FileProvider background thread upon exit
If the Threading::BackgroundAction for filesystem indexing in FileProvider hadn't finished by the time the main thread exited, it would still try to access the FileProvider object that lived in the main thread, thereby causing a segfault and crashing. This commit prevents FileProvider from being destroyed while the background thread is still running by giving the background thread a strong reference to its FileProvider.
This commit is contained in:
parent
ada1d4906e
commit
a610d9a3d1
1 changed files with 1 additions and 1 deletions
|
@ -164,7 +164,7 @@ void FileProvider::build_filesystem_cache()
|
|||
m_work_queue.enqueue("/");
|
||||
|
||||
(void)Threading::BackgroundAction<int>::construct(
|
||||
[this](auto&) {
|
||||
[this, strong_ref = NonnullRefPtr(*this)](auto&) {
|
||||
String slash = "/";
|
||||
auto timer = Core::ElapsedTimer::start_new();
|
||||
while (!m_work_queue.is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue