Attempted further memory leak prevention; fixed bugs from moving to python 12; misc.

This commit is contained in:
itdominator 2024-09-11 02:11:00 -05:00
parent 35456f2bca
commit 3a2e8eeb08
11 changed files with 47 additions and 51 deletions

View File

@ -48,7 +48,7 @@ class GrepPreviewWidget(Gtk.Box):
return bytes(f"\n<span foreground='{color}'>{target}</span>", "utf-8").decode("utf-8") return bytes(f"\n<span foreground='{color}'>{target}</span>", "utf-8").decode("utf-8")
def make_utf8_line_highlight(self, buffer, itr, i, color, target, query): def make_utf8_line_highlight(self, buffer, itr, i, color, target, query):
parts = re.split(r"(" + query + ")(?i)", target.replace("\n", "")) parts = re.split(r"(?i)(" + query + ")", target.replace("\n", ""))
for part in parts: for part in parts:
itr = buffer.get_end_iter() itr = buffer.get_end_iter()

View File

@ -8,6 +8,6 @@
"root": "./src/versions/solarfm-0.0.1/solarfm" "root": "./src/versions/solarfm-0.0.1/solarfm"
} }
], ],
"venvPath": ".", "venvPath": "/home/abaddon/Portable_Apps/py-venvs/pylsp-venv/",
"venv": ".venv" "venv": "venv"
} }

View File

@ -110,26 +110,30 @@ class HandlerMixin:
tab.move_file(fPath, tPath) tab.move_file(fPath, tPath)
else: else:
io_widget = IOWidget(action, file) io_widget = IOWidget(action, file)
io_list = self._builder.get_object("io_list")
io_list.add(io_widget)
io_list.show_all()
if action == "copy": if action == "copy":
file.copy_async(destination=target, file.copy_async(destination=target,
flags=Gio.FileCopyFlags.BACKUP, flags=Gio.FileCopyFlags.BACKUP,
io_priority=98, io_priority=45,
cancellable=io_widget.cancle_eve, cancellable=io_widget.cancle_eve,
progress_callback=io_widget.update_progress, progress_callback=io_widget.update_progress,
callback=io_widget.finish_callback) callback=io_widget.finish_callback)
self._builder.get_object("io_list").add(io_widget)
if action == "move" or action == "rename": if action == "move" or action == "rename":
file.move_async(destination=target, file.move_async(destination=target,
flags=Gio.FileCopyFlags.BACKUP, flags=Gio.FileCopyFlags.BACKUP,
io_priority=98, io_priority=45,
cancellable=io_widget.cancle_eve, cancellable=io_widget.cancle_eve,
progress_callback=None,
# NOTE: progress_callback here causes seg fault when set # NOTE: progress_callback here causes seg fault when set
progress_callback=None,
callback=io_widget.finish_callback) callback=io_widget.finish_callback)
self._builder.get_object("io_list").add(io_widget) io_widget = None
io_list = None
except GObject.GError as e: except GObject.GError as e:
raise OSError(e) raise OSError(e)

View File

@ -56,8 +56,9 @@ class GridMixin:
def update_store(self, i, store, icon): def update_store(self, i, store, icon):
itr = store.get_iter(i) itr = store.get_iter(i)
GLib.idle_add(self.insert_store, store, itr, icon) GLib.idle_add(self.insert_store, store, itr, icon.copy())
itr = None itr = None
del icon
@daemon_threaded @daemon_threaded
def make_and_load_icon(self, i, store, tab, dir, file): def make_and_load_icon(self, i, store, tab, dir, file):

View File

@ -264,15 +264,16 @@ class TabMixin(GridMixin):
path_menu_buttons.add(button) path_menu_buttons.add(button)
show_path_menu = True show_path_menu = True
path_menu_buttons = None
query = None query = None
files = None files = None
if not show_path_menu: if not show_path_menu:
path_menu_buttons = None
event_system.emit("hide_path_menu") event_system.emit("hide_path_menu")
else: else:
event_system.emit("show_path_menu") event_system.emit("show_path_menu")
buttons = path_menu_buttons.get_children() buttons = path_menu_buttons.get_children()
path_menu_buttons = None
if len(buttons) == 1: if len(buttons) == 1:
self.slowed_focus(buttons[0]) self.slowed_focus(buttons[0])

View File

@ -130,6 +130,10 @@ class WindowMixin(TabMixin):
self.update_tab(tab_label, state.tab, state.icon_grid.get_store(), state.wid, state.tid) self.update_tab(tab_label, state.tab, state.icon_grid.get_store(), state.wid, state.tid)
else: else:
event_system.emit("open_files") event_system.emit("open_files")
state = None
notebook = None
tab_label = None
except WindowException as e: except WindowException as e:
traceback.print_exc() traceback.print_exc()
self.display_message(settings.theming.error_color, f"{repr(e)}") self.display_message(settings.theming.error_color, f"{repr(e)}")

View File

@ -65,19 +65,20 @@ class IOWidget(Gtk.Box):
logger.info(f"Canceling: [{self._action}] of {self._basename} ...") logger.info(f"Canceling: [{self._action}] of {self._basename} ...")
eve.cancel() eve.cancel()
def update_progress(self, current, total, eve=None): def update_progress(self, current, total, eve = None):
self.progress.set_fraction(current/total) self.progress.set_fraction(current/total)
def finish_callback(self, file, task=None, eve=None): def finish_callback(self, file, task = None, eve = None):
if task.had_error():
logger.info(f"{self._action} of {self._basename} cancelled/failed...")
return
if self._action == "move" or self._action == "rename": if self._action == "move" or self._action == "rename":
status = self._file.move_finish(task) status = self._file.move_finish(task)
if self._action == "copy": if self._action == "copy":
status = self._file.copy_finish(task) status = self._file.copy_finish(task)
if status:
self.delete_self() self.delete_self()
else:
logger.info(f"{self._action} of {self._basename} failed...")
def delete_self(self, widget=None, eve=None): def delete_self(self, widget = None, eve = None):
self.get_parent().remove(self) self.get_parent().remove(self)

View File

@ -29,16 +29,16 @@ class PathMenuPopupWidget(Gtk.Popover):
self.set_relative_to(path_entry) self.set_relative_to(path_entry)
self.set_modal(False) self.set_modal(False)
self.set_position(Gtk.PositionType.BOTTOM) self.set_position(Gtk.PositionType.BOTTOM)
self.set_size_request(240, 420) self.set_size_request(480, 420)
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("show_path_menu", self.show_path_menu) event_system.subscribe("show_path_menu", self.show_path_menu)
event_system.subscribe("hide_path_menu", self.hide_path_menu) event_system.subscribe("hide_path_menu", self.hide_path_menu)
def _load_widgets(self): def _load_widgets(self):
path_menu_buttons = Gtk.ButtonBox()
scroll_window = Gtk.ScrolledWindow() scroll_window = Gtk.ScrolledWindow()
view_port = Gtk.Viewport() view_port = Gtk.Viewport()
path_menu_buttons = Gtk.Box()
scroll_window.set_vexpand(True) scroll_window.set_vexpand(True)
scroll_window.set_hexpand(True) scroll_window.set_hexpand(True)
@ -47,12 +47,13 @@ class PathMenuPopupWidget(Gtk.Popover):
self.builder.expose_object(f"path_menu_buttons", path_menu_buttons) self.builder.expose_object(f"path_menu_buttons", path_menu_buttons)
view_port.add(path_menu_buttons) view_port.add(path_menu_buttons)
scroll_window.add(view_port) scroll_window.add(view_port)
scroll_window.show_all()
self.add(scroll_window) self.add(scroll_window)
scroll_window.show_all()
def show_path_menu(self, widget=None, eve=None):
def show_path_menu(self, widget = None, eve = None):
self.popup() self.popup()
def hide_path_menu(self, widget=None, eve=None): def hide_path_menu(self, widget = None, eve = None):
self.popdown() self.popdown()

View File

@ -23,6 +23,7 @@ function main() {
export G_SLICE=always-malloc export G_SLICE=always-malloc
export G_DEBUG=gc-friendly export G_DEBUG=gc-friendly
export GOBJECT_DEBUG=instance-count export GOBJECT_DEBUG=instance-count
python /opt/solarfm.zip "${files[@]}" export GSK_RENDERER=cairo
python /opt/solarfm.zip "$@"
} }
main "$@"; main "$@";

View File

@ -1,17 +0,0 @@
#!/bin/bash
# . CONFIG.sh
# set -o xtrace ## To debug scripts
# set -o errexit ## To exit on error
# set -o errunset ## To exit if a variable is referenced but not set
function main() {
call_path=`pwd`
cd "${call_path}"
echo "Working Dir: " $(pwd)
python /opt/solarfm.zip "$@"
}
main "$@";