From a85a4721e3988756e3da1524219381214f8d599b Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Tue, 15 Oct 2024 20:39:03 +0200 Subject: [PATCH] Fixing double redraw when opening a file. --- common/src/module/canvas.mjs | 2 +- common/src/module/io.mjs | 1 - runtime-pyside6/LogarithmPlotter/util/debug.py | 3 +++ runtime-pyside6/LogarithmPlotter/util/latex.py | 4 +--- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/module/canvas.mjs b/common/src/module/canvas.mjs index 6abbf2d..913442f 100644 --- a/common/src/module/canvas.mjs +++ b/common/src/module/canvas.mjs @@ -530,7 +530,7 @@ class CanvasAPI extends Module { if(this.#redrawCount === currentRedrawCount) callback(imgData) else - console.log("2Discard render of", imgData.source, this.#redrawCount, currentRedrawCount) + console.log("1Discard render of", imgData.source, this.#redrawCount, currentRedrawCount) }) } else { // Callback directly diff --git a/common/src/module/io.mjs b/common/src/module/io.mjs index 472b061..92096e9 100644 --- a/common/src/module/io.mjs +++ b/common/src/module/io.mjs @@ -201,7 +201,6 @@ class IOAPI extends Module { // TODO: Error handling return } - Canvas.redraw() this.#alert.show(qsTranslate("io", "Loaded file '%1'.").arg(basename)) this.#saved = true this.emit(new LoadedEvent()) diff --git a/runtime-pyside6/LogarithmPlotter/util/debug.py b/runtime-pyside6/LogarithmPlotter/util/debug.py index 8b57687..f899fd5 100644 --- a/runtime-pyside6/LogarithmPlotter/util/debug.py +++ b/runtime-pyside6/LogarithmPlotter/util/debug.py @@ -19,10 +19,12 @@ from PySide6.QtCore import QtMsgType, qInstallMessageHandler, QMessageLogContext from math import ceil, log10 from os import path +from re import compile CURRENT_PATH = path.dirname(path.realpath(__file__)) SOURCEMAP_PATH = path.realpath(f"{CURRENT_PATH}/../qml/eu/ad5001/LogarithmPlotter/js/index.mjs.map") SOURCEMAP_INDEX = None +INDEX_REG = compile(r"build\/runtime-pyside6\/LogarithmPlotter\/qml\/eu\/ad5001\/LogarithmPlotter\/js\/index.mjs:(\d+)") class LOG_COLORS: @@ -77,6 +79,7 @@ def create_log_terminal_message(mode: QtMsgType, context: QMessageLogContext, me # Check MJS if line is not None and source_file is not None and source_file.endswith("index.mjs"): source_file, line = map_javascript_source(source_file, line) + # Parse message prefix = f"{LOG_COLORS.INVERT}{mode[1]}[{mode[0].upper()}]{LOG_COLORS.RESET_INVERT}" message = message + LOG_COLORS.RESET context = f"{context.function} at {source_file}:{line}" diff --git a/runtime-pyside6/LogarithmPlotter/util/latex.py b/runtime-pyside6/LogarithmPlotter/util/latex.py index 2db62eb..f36f07f 100644 --- a/runtime-pyside6/LogarithmPlotter/util/latex.py +++ b/runtime-pyside6/LogarithmPlotter/util/latex.py @@ -150,11 +150,9 @@ class Latex(QObject): promise = self.render_pipeline_locks[render_hash] elif markup_hash in self.render_pipeline_locks: # A PyPromise with the same markup, but not the same color or font size is already running. - print("Chaining render of", latex_markup) + # print("Chaining render of", latex_markup) existing_promise = self.render_pipeline_locks[markup_hash] promise = self._create_async_promise(latex_markup, font_size, color) - existing_promise.then(lambda x, latex_markup=latex_markup: print("> Starting chained render of", latex_markup)) - promise.then(lambda x, latex_markup=latex_markup: print("> Fulfilled chained render of", latex_markup, "\n with", x.toVariant())) existing_promise.then(promise.start) else: # No such PyPromise is running.