fixed some memory leaking issues; added event pause/resume functionality
This commit is contained in:
parent
8862a80eea
commit
ce0f45e168
@ -164,6 +164,8 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
|
||||
event_system.emit("show_plugins_popup")
|
||||
if action == "messages_popup":
|
||||
event_system.emit("show_messages_popup")
|
||||
if action == "ui_debug":
|
||||
event_system.emit("load_interactive_debug")
|
||||
if action == "tear_down":
|
||||
event_system.emit("tear_down")
|
||||
|
||||
@ -190,4 +192,4 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
|
||||
tab.execute([f"{tab.terminal_app}"], start_dir=tab.get_current_directory())
|
||||
|
||||
def go_to_path(self, path: str):
|
||||
self.builder.get_object("path_entry").set_text(path)
|
||||
self.builder.get_object("path_entry").set_text(path)
|
@ -55,6 +55,10 @@ class Controller_Data:
|
||||
self.shift_down = False
|
||||
self.alt_down = False
|
||||
|
||||
self._state = State()
|
||||
self.message_dialog = MessageWidget()
|
||||
self.user_pass_dialog = UserPassWidget()
|
||||
|
||||
|
||||
def get_current_state(self) -> State:
|
||||
'''
|
||||
@ -66,7 +70,8 @@ class Controller_Data:
|
||||
Returns:
|
||||
state (obj): State
|
||||
'''
|
||||
state = State()
|
||||
# state = State()
|
||||
state = self._state
|
||||
state.fm_controller = self.fm_controller
|
||||
state.notebooks = self.notebooks
|
||||
state.wid, state.tid = self.fm_controller.get_active_wid_and_tid()
|
||||
@ -74,8 +79,14 @@ class Controller_Data:
|
||||
state.icon_grid = self.builder.get_object(f"{state.wid}|{state.tid}|icon_grid", use_gtk = False)
|
||||
# state.icon_grid = event_system.emit_and_await("get_files_view_icon_grid", (state.wid, state.tid))
|
||||
state.store = state.icon_grid.get_model()
|
||||
state.message_dialog = MessageWidget()
|
||||
state.user_pass_dialog = UserPassWidget()
|
||||
|
||||
# NOTE: Need to watch this as I thought we had issues with just using single reference upon closing it.
|
||||
# But, I found that not doing it this way caused objects to generate upon every click... (Because we're getting state info, duh)
|
||||
# Yet interactive debug view shows them just pilling on and never clearing...
|
||||
state.message_dialog = self.message_dialog
|
||||
state.user_pass_dialog = self.user_pass_dialog
|
||||
# state.message_dialog = MessageWidget()
|
||||
# state.user_pass_dialog = UserPassWidget()
|
||||
|
||||
selected_files = state.icon_grid.get_selected_items()
|
||||
if selected_files:
|
||||
|
@ -26,14 +26,15 @@ class GridMixin:
|
||||
store.append([None, file[0]])
|
||||
|
||||
Gtk.main_iteration()
|
||||
# for i, file in enumerate(files):
|
||||
# self.create_icon(i, tab, store, dir, file[0])
|
||||
|
||||
if use_generator:
|
||||
# NOTE: tab > icon > _get_system_thumbnail_gtk_thread must not be used
|
||||
# as the attempted promotion back to gtk threading stalls the generator. (We're already in main gtk thread)
|
||||
for i, icon in enumerate( self.create_icons_generator(tab, dir, files) ):
|
||||
self.load_icon(i, store, icon)
|
||||
else:
|
||||
# for i, file in enumerate(files):
|
||||
# self.create_icon(i, tab, store, dir, file[0])
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
|
@ -73,13 +73,9 @@ class TabMixin(GridMixin):
|
||||
self.builder.dereference_object(f"{wid}|{tid}")
|
||||
|
||||
store.clear()
|
||||
# store.run_dispose()
|
||||
icon_grid.destroy()
|
||||
# icon_grid.run_dispose()
|
||||
scroll.destroy()
|
||||
#scroll.run_dispose()
|
||||
tab_box.destroy()
|
||||
# tab_box.run_dispose()
|
||||
|
||||
del store
|
||||
del icon_grid
|
||||
|
@ -53,6 +53,7 @@ class Window(Gtk.ApplicationWindow):
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("tear_down", self._tear_down)
|
||||
event_system.subscribe("load_interactive_debug", self._load_interactive_debug)
|
||||
|
||||
def _load_widgets(self, args, unknownargs):
|
||||
if settings_manager.is_debug():
|
||||
@ -86,9 +87,12 @@ class Window(Gtk.ApplicationWindow):
|
||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
||||
|
||||
def _load_interactive_debug(self):
|
||||
self.set_interactive_debugging(True)
|
||||
|
||||
|
||||
def _tear_down(self, widget = None, eve = None):
|
||||
event_system.emit("shutting_down")
|
||||
settings_manager.clear_pid()
|
||||
Gtk.main_quit()
|
||||
Gtk.main_quit()
|
@ -13,7 +13,20 @@ class EventSystem(Singleton):
|
||||
|
||||
def __init__(self):
|
||||
self.subscribers = defaultdict(list)
|
||||
self._is_paused = False
|
||||
|
||||
self._subscribe_to_events()
|
||||
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
self.subscribe("pause_event_processing", self._pause_processing_events)
|
||||
self.subscribe("resume_event_processing", self._resume_processing_events)
|
||||
|
||||
def _pause_processing_events(self):
|
||||
self._is_paused = True
|
||||
|
||||
def _resume_processing_events(self):
|
||||
self._is_paused = False
|
||||
|
||||
def subscribe(self, event_type, fn):
|
||||
self.subscribers[event_type].append(fn)
|
||||
@ -25,6 +38,9 @@ class EventSystem(Singleton):
|
||||
self.subscribers.pop(event_type, None)
|
||||
|
||||
def emit(self, event_type, data = None):
|
||||
if self._is_paused and event_type != "resume_event_processing":
|
||||
return
|
||||
|
||||
if event_type in self.subscribers:
|
||||
for fn in self.subscribers[event_type]:
|
||||
if data:
|
||||
@ -36,6 +52,9 @@ class EventSystem(Singleton):
|
||||
fn()
|
||||
|
||||
def emit_and_await(self, event_type, data = None):
|
||||
if self._is_paused and event_type != "resume_event_processing":
|
||||
return
|
||||
|
||||
""" NOTE: Should be used when signal has only one listener and vis-a-vis """
|
||||
if event_type in self.subscribers:
|
||||
response = None
|
||||
|
Loading…
Reference in New Issue
Block a user