Fixing vod thumbnailer; handling signal removal on tab close

+ more attempts at leak fixes; thumbnailer plugin updates and corrections
This commit is contained in:
2025-08-15 22:23:51 -05:00
parent e0723e7b9e
commit d96ace1504
22 changed files with 225 additions and 860 deletions

View File

@@ -50,8 +50,8 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
if not thumbnl:
# TODO: Detect if not in a thread and use directly for speed get_system_thumbnail
thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
# thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
# thumbnl = self.get_system_thumbnail(full_path, self.sys_icon_wh[0])
thumbnl = self._get_system_thumbnail_gtk_thread(full_path, self.sys_icon_wh[0])
if not thumbnl:
raise IconException("No known icons found.")
@@ -144,6 +144,8 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
event = threading.Event()
GLib.idle_add(_call_gtk_thread, event, result)
event.wait()
event = None
return result[0]
@@ -156,6 +158,7 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
if data:
icon_path = data.get_filename()
return GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, width = size, height = size)
raise IconException("No system icon found...")
@@ -202,4 +205,4 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
False, 8, w, h, w * 3)
return pixbuf.scale_simple(wxh[0], wxh[1], 2) # BILINEAR = 2
return pixbuf.scale_simple(wxh[0], wxh[1], 2) # BILINEAR = 2

View File

@@ -21,6 +21,10 @@ class Plugin(PluginBase):
def run(self):
self.icon_controller = IconController()
self._event_system.subscribe("create-thumbnail", self.create_thumbnail)
self._event_system.subscribe("create-video-thumbnail", self.create_video_thumbnail)
self._event_system.subscribe("create-scaled-image", self.create_scaled_image)
self._event_system.subscribe("get-thumbnail-hash", self.get_thumbnail_hash)
self._event_system.subscribe("get-thumbnails-path", self.get_thumbnails_path)
def generate_reference_ui_element(self):
...
@@ -28,6 +32,18 @@ class Plugin(PluginBase):
def create_thumbnail(self, dir, file) -> str:
return self.icon_controller.create_icon(dir, file)
def create_video_thumbnail(self, file, scrub_percent, replace):
return self.icon_controller.create_video_thumbnail(file, scrub_percent, replace)
def create_scaled_image(self, hash_img_pth):
return self.icon_controller.create_scaled_image(hash_img_pth)
def get_thumbnail_hash(self, file):
return self.icon_controller.generate_hash_and_path(file)
def get_thumbnails_path(self) -> str:
return self.icon_controller.ABS_THUMBS_PTH
def get_video_icons(self, dir) -> list:
data = []

View File

@@ -26,6 +26,8 @@ def threaded(fn):
return wrapper
class VODThumbnailerException(Exception):
...
class Plugin(PluginBase):
@@ -94,32 +96,39 @@ class Plugin(PluginBase):
file = self._file_name.get_text()
dir = self._file_location.get_text()
file_hash = self._file_hash.get_text()
hash_img_pth = f"{self._fm_state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
hash_img_pth = f"{self.ABS_THUMBS_PTH}/{file_hash}.jpg"
try:
self._fm_state.tab.create_video_thumbnail(f"{dir}/{file}", f"{scrub_percent}%", True)
self._event_system.emit_and_await("create-video-thumbnail", (f"{dir}/{file}", f"{scrub_percent}%", True,))
preview_pixbuf = GdkPixbuf.Pixbuf.new_from_file(hash_img_pth)
self._thumbnail_preview_img.set_from_pixbuf(preview_pixbuf)
img_pixbuf = self._fm_state.tab.create_scaled_image(hash_img_pth)
img_pixbuf = self._event_system.emit_and_await("create-scaled-image", (hash_img_pth,))
tree_pth = self._fm_state.icon_grid.get_selected_items()[0]
itr = self._fm_state.store.get_iter(tree_pth)
pixbuff = self._fm_state.store.get(itr, 0)[0]
self._fm_state.store.set(itr, 0, img_pixbuf)
except Exception as e:
print(repr(e))
print("Couldn't regenerate thumbnail!")
print(repr(e))
def _set_ui_data(self):
uri = self._fm_state.uris[0]
path = self._fm_state.tab.get_current_directory()
parts = uri.split("/")
file_hash = self._fm_state.tab.fast_hash(uri)
hash_img_pth = f"{self._fm_state.tab.ABS_THUMBS_PTH}/{file_hash}.jpg"
path_exists,
img_hash,
hash_img_pth = self._event_system.emit_and_await("get-thumbnail-hash", (uri,))
if not path_exists:
raise VODThumbnailerException(f"Could not generate file_hash from: {uri}")
self.ABS_THUMBS_PTH = self._event_system.emit_and_await("get-thumbnails-path")
preview_pixbuf = GdkPixbuf.Pixbuf.new_from_file(hash_img_pth)
self._thumbnail_preview_img.set_from_pixbuf(preview_pixbuf)
self._file_name.set_text(parts[ len(parts) - 1 ])
self._file_location.set_text(path)
self._file_hash.set_text(file_hash)
self._file_hash.set_text(img_hash)

View File

@@ -47,4 +47,4 @@ class Plugin(PluginBase):
@threaded
def _download(self, dir):
subprocess.Popen([f'{self.path}/download.sh', dir])
subprocess.Popen([f'{self.path}/download.sh', dir], start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True)