diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index dcc6fc51..2a0a5698 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -74,9 +74,7 @@ class QUnFrameWindow(resizableframeless): try: if len(iter_res_info): starting,klass=iter_res_info - print(starting,klass,res) if not starting: - print(self.saveiterclasspointer[klass]) self.translate_text.insertatpointer(self.saveiterclasspointer[klass],res) self.saveiterclasspointer[klass]=self.translate_text.getcurrpointer() return diff --git a/LunaTranslator/LunaTranslator/translator/basetranslator.py b/LunaTranslator/LunaTranslator/translator/basetranslator.py index fc5f0637..abc236fa 100644 --- a/LunaTranslator/LunaTranslator/translator/basetranslator.py +++ b/LunaTranslator/LunaTranslator/translator/basetranslator.py @@ -79,6 +79,7 @@ class basetrans(commonbase): self._safe_private_init() self.lastrequesttime=0 + self.requestid=0 self._cache={} self.newline=None @@ -248,9 +249,9 @@ class basetrans(commonbase): if is_auto_run and self.onlymanual: continue - + self.requestid+=1 try: - checktutukufunction=lambda:( (embedcallback is not None) or self.queue.empty()) and self.using + checktutukufunction=lambda:( (embedcallback is not None) or self.queue.empty()) and self.using if checktutukufunction(): def reinitandtrans(): if self.needreinit: @@ -266,8 +267,13 @@ class basetrans(commonbase): callback(_,embedcallback,is_iter_res) collectiterres.append(_) if isinstance(res,types.GeneratorType): - for _res in res: - __callback(_res,True) + def _iterget(): + rid=self.requestid + for _res in res: + if self.requestid!=rid:break + __callback(_res,True) + timeoutfunction(_iterget,checktutukufunction=checktutukufunction ) + else: __callback(res,False) self.cachesetatend(contentsolved,''.join(collectiterres))