Fixed core dumped on close
This commit is contained in:
@@ -134,13 +134,11 @@ class ScannerWorker(QRunnable):
|
||||
sizes_to_check = self.target_sizes if self.target_sizes is not None \
|
||||
else SCANNER_GENERATE_SIZES
|
||||
|
||||
if self._is_cancelled:
|
||||
if self.semaphore:
|
||||
self.semaphore.release()
|
||||
return
|
||||
|
||||
fd = None
|
||||
try:
|
||||
if self._is_cancelled:
|
||||
return
|
||||
|
||||
fd = None
|
||||
# Optimize: Open file once to reuse FD for stat and xattrs
|
||||
fd = os.open(self.path, os.O_RDONLY)
|
||||
stat_res = os.fstat(fd)
|
||||
@@ -285,6 +283,7 @@ class CacheWriter(QThread):
|
||||
self._condition_new_data = QWaitCondition()
|
||||
self._condition_space_available = QWaitCondition()
|
||||
# Soft limit for blocking producers (background threads)
|
||||
self.setObjectName("CacheWriterThread") # Add this line
|
||||
self._max_size = 50
|
||||
self._running = True
|
||||
|
||||
@@ -334,6 +333,7 @@ class CacheWriter(QThread):
|
||||
self._running = False
|
||||
# Do not clear the queue here; let the run loop drain it to prevent data loss.
|
||||
self._condition_new_data.wakeAll()
|
||||
logger.debug(f"{self.objectName()} stop requested, waking all.")
|
||||
self._condition_space_available.wakeAll()
|
||||
self._mutex.unlock()
|
||||
|
||||
@@ -380,6 +380,7 @@ class CacheWriter(QThread):
|
||||
self.cache._batch_write_to_lmdb(batch)
|
||||
except Exception as e:
|
||||
logger.error(f"CacheWriter batch write error: {e}")
|
||||
logger.debug(f"{self.objectName()} run method exiting.")
|
||||
|
||||
|
||||
class CacheLoader(QThread):
|
||||
@@ -1328,6 +1329,7 @@ class CacheCleaner(QThread):
|
||||
def stop(self):
|
||||
"""Signals the thread to stop."""
|
||||
self._is_running = False
|
||||
self.wait()
|
||||
|
||||
def run(self):
|
||||
self.setPriority(QThread.IdlePriority)
|
||||
@@ -1914,3 +1916,4 @@ class ImageScanner(QThread):
|
||||
self.mutex.lock()
|
||||
self.condition.wakeAll()
|
||||
self.mutex.unlock()
|
||||
self.wait()
|
||||
|
||||
Reference in New Issue
Block a user