Fixing double redraw when opening a file.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Adsooi 2024-10-15 20:39:03 +02:00
parent aeaaba759f
commit a85a4721e3
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
4 changed files with 5 additions and 5 deletions

View file

@ -530,7 +530,7 @@ class CanvasAPI extends Module {
if(this.#redrawCount === currentRedrawCount) if(this.#redrawCount === currentRedrawCount)
callback(imgData) callback(imgData)
else else
console.log("2Discard render of", imgData.source, this.#redrawCount, currentRedrawCount) console.log("1Discard render of", imgData.source, this.#redrawCount, currentRedrawCount)
}) })
} else { } else {
// Callback directly // Callback directly

View file

@ -201,7 +201,6 @@ class IOAPI extends Module {
// TODO: Error handling // TODO: Error handling
return return
} }
Canvas.redraw()
this.#alert.show(qsTranslate("io", "Loaded file '%1'.").arg(basename)) this.#alert.show(qsTranslate("io", "Loaded file '%1'.").arg(basename))
this.#saved = true this.#saved = true
this.emit(new LoadedEvent()) this.emit(new LoadedEvent())

View file

@ -19,10 +19,12 @@
from PySide6.QtCore import QtMsgType, qInstallMessageHandler, QMessageLogContext from PySide6.QtCore import QtMsgType, qInstallMessageHandler, QMessageLogContext
from math import ceil, log10 from math import ceil, log10
from os import path from os import path
from re import compile
CURRENT_PATH = path.dirname(path.realpath(__file__)) CURRENT_PATH = path.dirname(path.realpath(__file__))
SOURCEMAP_PATH = path.realpath(f"{CURRENT_PATH}/../qml/eu/ad5001/LogarithmPlotter/js/index.mjs.map") SOURCEMAP_PATH = path.realpath(f"{CURRENT_PATH}/../qml/eu/ad5001/LogarithmPlotter/js/index.mjs.map")
SOURCEMAP_INDEX = None SOURCEMAP_INDEX = None
INDEX_REG = compile(r"build\/runtime-pyside6\/LogarithmPlotter\/qml\/eu\/ad5001\/LogarithmPlotter\/js\/index.mjs:(\d+)")
class LOG_COLORS: class LOG_COLORS:
@ -77,6 +79,7 @@ def create_log_terminal_message(mode: QtMsgType, context: QMessageLogContext, me
# Check MJS # Check MJS
if line is not None and source_file is not None and source_file.endswith("index.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) 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}" prefix = f"{LOG_COLORS.INVERT}{mode[1]}[{mode[0].upper()}]{LOG_COLORS.RESET_INVERT}"
message = message + LOG_COLORS.RESET message = message + LOG_COLORS.RESET
context = f"{context.function} at {source_file}:{line}" context = f"{context.function} at {source_file}:{line}"

View file

@ -150,11 +150,9 @@ class Latex(QObject):
promise = self.render_pipeline_locks[render_hash] promise = self.render_pipeline_locks[render_hash]
elif markup_hash in self.render_pipeline_locks: 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. # 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] existing_promise = self.render_pipeline_locks[markup_hash]
promise = self._create_async_promise(latex_markup, font_size, color) 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) existing_promise.then(promise.start)
else: else:
# No such PyPromise is running. # No such PyPromise is running.