From 17bdcf5cb2cb6fb1c1ac3f6106b57df12069ed67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Tue, 14 May 2024 21:30:53 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/textsource/texthook.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index e86f8e0e..60beaac3 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -52,6 +52,9 @@ class ThreadParam(Structure): def __eq__(self, __value): return self.__hash__() == __value.__hash__() + def __repr__(self): + return "(%s,%s,%s,%s)" % (self.processId, self.addr, self.ctx, self.ctx2) + class SearchParam(Structure): _fields_ = [ @@ -305,7 +308,7 @@ class texthook(basetext): ) def onremovehook(self, hc, hn, tp): - key = (hc, hn.decode('utf8'), tp) + key = (hc, hn.decode("utf8"), tp) self.hookdatacollecter.pop(key) gobject.baseobject.hookselectdialog.removehooksignal.emit(key) @@ -322,6 +325,10 @@ class texthook(basetext): def onnewhook(self, hc, hn, tp): key = (hc, hn.decode("utf8"), tp) + + self.hookdatacollecter[key] = [] + self.hooktypecollecter[key] = 0 + if self.isremoveuseless: if tp.addr not in [_[1] for _ in self.autostarthookcode]: self.Luna_RemoveHook(tp.processId, tp.addr) @@ -334,9 +341,6 @@ class texthook(basetext): self.selectinghook = key select = True break - - self.hookdatacollecter[key] = [] - self.hooktypecollecter[key] = 0 gobject.baseobject.hookselectdialog.addnewhooksignal.emit(key, select) return True