mirror of
https://github.com/slgobinath/SafeEyes.git
synced 2024-12-24 23:50:46 +01:00
Fix crash in smartpause (#582)
* smartpause: fix calling disable_safeeyes on main thread
by adding missing parameter
This was missed in 903d407faf
* fix forwarding arguments in execute_main_thread
This broke when the first parameter was None, but the second wasn't (the
second parameter wasn't passed at all.)
Use *args/**kwargs to make it behave properly in all cases.
This commit is contained in:
parent
ba14a6831e
commit
4c43de8fff
@ -71,8 +71,8 @@ class SafeEyes:
|
|||||||
self.show_about)
|
self.show_about)
|
||||||
self.context['api']['enable_safeeyes'] = lambda next_break_time=-1, reset_breaks=False: \
|
self.context['api']['enable_safeeyes'] = lambda next_break_time=-1, reset_breaks=False: \
|
||||||
utility.execute_main_thread(self.enable_safeeyes, next_break_time, reset_breaks)
|
utility.execute_main_thread(self.enable_safeeyes, next_break_time, reset_breaks)
|
||||||
self.context['api']['disable_safeeyes'] = lambda status: utility.execute_main_thread(
|
self.context['api']['disable_safeeyes'] = lambda status=None, is_resting=False: utility.execute_main_thread(
|
||||||
self.disable_safeeyes, status)
|
self.disable_safeeyes, status, is_resting)
|
||||||
self.context['api']['status'] = self.status
|
self.context['api']['status'] = self.status
|
||||||
self.context['api']['quit'] = lambda: utility.execute_main_thread(
|
self.context['api']['quit'] = lambda: utility.execute_main_thread(
|
||||||
self.quit)
|
self.quit)
|
||||||
|
@ -94,28 +94,16 @@ def start_thread(target_function, **args):
|
|||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
# def execute_main_thread(target_function, args=None):
|
# def execute_main_thread(target_function, *args, **kwargs):
|
||||||
# """
|
# """
|
||||||
# Execute the given function in main thread.
|
# Execute the given function in main thread, forwarding positional and keyword arguments.
|
||||||
# """
|
# """
|
||||||
# if args:
|
|
||||||
# GLib.idle_add(lambda: target_function(args))
|
|
||||||
# else:
|
|
||||||
# GLib.idle_add(target_function)
|
|
||||||
|
|
||||||
def execute_main_thread(target_function, arg1=None, arg2=None):
|
def execute_main_thread(target_function, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Execute the given function in main thread.
|
Execute the given function in main thread.
|
||||||
"""
|
"""
|
||||||
if arg1 is not None and arg2 is not None:
|
GLib.idle_add(lambda: target_function(*args, **kwargs))
|
||||||
GLib.idle_add(lambda: target_function(arg1, arg2))
|
|
||||||
elif arg1 is not None:
|
|
||||||
GLib.idle_add(lambda: target_function(arg1))
|
|
||||||
elif arg2 is not None:
|
|
||||||
GLib.idle_add(lambda: target_function(arg2))
|
|
||||||
else:
|
|
||||||
GLib.idle_add(target_function)
|
|
||||||
|
|
||||||
|
|
||||||
def system_locale(category=locale.LC_MESSAGES):
|
def system_locale(category=locale.LC_MESSAGES):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user