diff --git a/BatchCreator/BatchCreator_mini_windows_explorer.py b/BatchCreator/BatchCreator_mini_windows_explorer.py index eda2a7f6..22db95e4 100644 --- a/BatchCreator/BatchCreator_mini_windows_explorer.py +++ b/BatchCreator/BatchCreator_mini_windows_explorer.py @@ -8,6 +8,7 @@ class CustomFileSystemModel(QFileSystemModel): NAME_COLUMN = 0 SIZE_COLUMN = 1 + CACHE_LIMIT = 100 # Set a limit for the cache size def __init__(self, parent=None): super().__init__(parent) @@ -28,8 +29,15 @@ def data(self, index, role): if not self.isDir(index): file_name = QFileInfo(file_name).completeBaseName() self._cache[file_path] = file_name + if len(self._cache) > self.CACHE_LIMIT: + self._clean_cache() # Clean up the cache if it exceeds the limit return file_name return super().data(index, role) + + def _clean_cache(self): + # Implement logic to clean up the cache, for example, removing the oldest entries + # Here you can decide how to clean up the cache based on your requirements + self._cache = {} # Resetting the cache in this example def supportedDropActions(self): return Qt.MoveAction diff --git a/main.py b/main.py index 68db93f2..3818b5e7 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ -import sys, os, subprocess, threading, portalocker, tempfile, webbrowser, time, socket -from PySide6.QtWidgets import QApplication, QWidget, QSystemTrayIcon, QMenu, QMessageBox +import sys, os, threading, portalocker, tempfile, webbrowser, time, socket, logging +from PySide6.QtWidgets import QApplication, QWidget, QSystemTrayIcon, QMenu from PySide6.QtGui import QIcon, QAction from ui_form import Ui_Widget from qt_styles.qt_global_stylesheet import QT_Stylesheet_global @@ -26,10 +26,7 @@ app_version = '1.2.1' batchcreator_version = '1.0.0' - - class Widget(QWidget): - def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_Widget() @@ -111,18 +108,18 @@ def selected_addon_name(self): # Clean up SoundEventEditorMainWidget try: - if self.SoundEventEditorMainWidget: + if hasattr(self, 'SoundEventEditorMainWidget') and self.SoundEventEditorMainWidget: self.SoundEventEditorMainWidget.deleteLater() except Exception as e: print(f"Error while cleaning up SoundEventEditorMainWidget: {e}") - # Create a new instance of SoundEventEditorMainWidget + # # Check if the current tab is the soundeditor_tab self.SoundEventEditorMainWidget = SoundEventEditorMainWidget() self.ui.soundeditor_tab.layout().addWidget(self.SoundEventEditorMainWidget) # Clean up BatchCreator_MainWindow try: - if self.BatchCreator_MainWindow: + if hasattr(self, 'BatchCreator_MainWindow') and self.BatchCreator_MainWindow: self.BatchCreator_MainWindow.deleteLater() self.BatchCreator_MainWindow = None except Exception as e: