mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
lock
This commit is contained in:
parent
c021aca406
commit
a29f16186b
@ -45,15 +45,6 @@ from winsharedutils import pid_running
|
||||
from myutils.post import POSTSOLVE
|
||||
|
||||
|
||||
class _autolock:
|
||||
def __init__(self, lock) -> None:
|
||||
self.lock = lock
|
||||
lock.acquire()
|
||||
|
||||
def __del__(self):
|
||||
self.lock.release()
|
||||
|
||||
|
||||
class MAINUI:
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
@ -143,7 +134,12 @@ class MAINUI:
|
||||
def textgetmethod(
|
||||
self, text, is_auto_run=True, embedcallback=None, onlytrans=False
|
||||
):
|
||||
_autolock(self.solvegottextlock)
|
||||
with self.solvegottextlock:
|
||||
return self.textgetmethod_1(text, is_auto_run, embedcallback, onlytrans)
|
||||
|
||||
def textgetmethod_1(
|
||||
self, text, is_auto_run=True, embedcallback=None, onlytrans=False
|
||||
):
|
||||
|
||||
returnandembedcallback = lambda: embedcallback("") if embedcallback else ""
|
||||
|
||||
|
@ -904,8 +904,6 @@ class hookselect(closeashidewindow):
|
||||
def accept(self, key, select):
|
||||
try:
|
||||
|
||||
gobject.baseobject.textsource.lock.acquire()
|
||||
|
||||
if key in gobject.baseobject.textsource.selectedhook:
|
||||
gobject.baseobject.textsource.selectedhook.remove(key)
|
||||
|
||||
@ -928,7 +926,6 @@ class hookselect(closeashidewindow):
|
||||
savehook_new_data[gobject.baseobject.textsource.pname].update(
|
||||
{"hook": gobject.baseobject.textsource.selectedhook}
|
||||
)
|
||||
gobject.baseobject.textsource.lock.release()
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
|
@ -94,7 +94,6 @@ class texthook(basetext):
|
||||
self.newline = Queue()
|
||||
self.newline_delaywait = Queue()
|
||||
self.is64bit = Is64bit(pids[0])
|
||||
self.lock = threading.Lock()
|
||||
self.hookdatacollecter = OrderedDict()
|
||||
self.hooktypecollecter = OrderedDict()
|
||||
self.currentname = None
|
||||
@ -312,14 +311,13 @@ class texthook(basetext):
|
||||
|
||||
def onremovehook(self, tp):
|
||||
toremove = []
|
||||
self.lock.acquire()
|
||||
|
||||
for key in self.hookdatacollecter:
|
||||
if key[1] == tp.addr:
|
||||
toremove.append(key)
|
||||
for key in toremove:
|
||||
gobject.baseobject.hookselectdialog.removehooksignal.emit(key)
|
||||
self.hookdatacollecter.pop(key)
|
||||
self.lock.release()
|
||||
|
||||
def parsetextthread(self, hc, hn, tp):
|
||||
key = (tp.processId, tp.addr, tp.ctx, tp.ctx2, hn.decode("ascii"), hc)
|
||||
@ -344,7 +342,7 @@ class texthook(basetext):
|
||||
self.Luna_RemoveHook(key[0], key[1])
|
||||
return False
|
||||
|
||||
self.lock.acquire()
|
||||
|
||||
select = False
|
||||
for _i, autostarthookcode in enumerate(self.autostarthookcode):
|
||||
if self.match_compatibility(key, autostarthookcode):
|
||||
@ -358,7 +356,6 @@ class texthook(basetext):
|
||||
gobject.baseobject.hookselectdialog.addnewhooksignal.emit(
|
||||
key, select, [hc, hn, tp]
|
||||
)
|
||||
self.lock.release()
|
||||
return True
|
||||
|
||||
def setsettings(self):
|
||||
@ -462,7 +459,7 @@ class texthook(basetext):
|
||||
if key not in self.hookdatacollecter:
|
||||
if self.onnewhook(hc, hn, tp) == False:
|
||||
return False
|
||||
self.lock.acquire()
|
||||
|
||||
if self.hooktypecollecter[key] == 1:
|
||||
self.currentname = output
|
||||
if len(self.selectedhook) == 1:
|
||||
@ -479,7 +476,6 @@ class texthook(basetext):
|
||||
self.hookdatacollecter[key] = self.hookdatacollecter[key][-100:]
|
||||
gobject.baseobject.hookselectdialog.update_item_new_line.emit(key, output)
|
||||
|
||||
self.lock.release()
|
||||
return True
|
||||
|
||||
def checkisusingembed(self, address, ctx1, ctx2):
|
||||
|
Loading…
x
Reference in New Issue
Block a user