From fe31f93c94dbe0b1a6349edf7b523a44b36a294b Mon Sep 17 00:00:00 2001 From: "Julien Carion (juca)" Date: Thu, 27 Apr 2023 12:57:57 +0200 Subject: [PATCH] [FIX] devtools: fix apps patching and reload This commit fixes issues introduced in the previous fix for the apps methods patching and also fixes the status of the profiler tracing on reload. --- tools/devtools/src/devtools_app/store/store.js | 3 +++ .../page_scripts/owl_devtools_global_hook.js | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/devtools/src/devtools_app/store/store.js b/tools/devtools/src/devtools_app/store/store.js index ead97046..d6389ee9 100644 --- a/tools/devtools/src/devtools_app/store/store.js +++ b/tools/devtools/src/devtools_app/store/store.js @@ -509,7 +509,10 @@ export const store = reactive({ this.eventsTree = []; this.activeRecorder = false; evalFunctionInWindow("toggleEventsRecording", [false, 0]); + this.traceRenderings = false; evalFunctionInWindow("toggleTracing", [false]); + this.traceSubscriptions = false; + evalFunctionInWindow("toggleSubscriptionTracing", [false]); }, // Triggers manually the rendering of the selected component diff --git a/tools/devtools/src/page_scripts/owl_devtools_global_hook.js b/tools/devtools/src/page_scripts/owl_devtools_global_hook.js index 31a762f9..fb9a2cd1 100644 --- a/tools/devtools/src/page_scripts/owl_devtools_global_hook.js +++ b/tools/devtools/src/page_scripts/owl_devtools_global_hook.js @@ -46,6 +46,9 @@ this.appsPatched = false; this.destroyPatched = false; this.patchAppsSetMethods(); + if (this.apps.size > 0) { + this.patchAppMethods(); + } this.recordEvents = false; this.traceRenderings = false; this.traceSubscriptions = false; @@ -241,13 +244,22 @@ return; } let app = this.apps.values().next().value; - if (!app) { - return; + const self = this; + if (app.root) { + this.patchDestroyMethod(app.root); + } else { + const originalMount = app.constructor.prototype.mount; + app.constructor.prototype.mount = async function (...args) { + const result = await originalMount.call(this, ...args); + const root = this.root; + self.patchDestroyMethod(root); + app.constructor.prototype.mount = originalMount; + return result; + }; } const originalFlush = app.scheduler.constructor.prototype.flush; let inFlush = false; let _render = false; - const self = this; app.scheduler.constructor.prototype.flush = function () { // Used to know when a render is triggered inside the flush method or not inFlush = true;