mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: protect against user code executing in critical section
Canceling a fiber may cause user code to be run, which means that some new renderings could be scheduled, but this could interfere with the current renderings!
This commit is contained in:
committed by
Sam Degueldre
parent
7fb166bd50
commit
fd13277e1d
@@ -79,10 +79,8 @@ export function component<P extends object>(
|
||||
let node: any = ctx.children[key];
|
||||
let isDynamic = typeof name !== "string";
|
||||
|
||||
if (node) {
|
||||
if (node.status === STATUS.DESTROYED) {
|
||||
node = undefined;
|
||||
}
|
||||
if (node && node.status === STATUS.DESTROYED) {
|
||||
node = undefined;
|
||||
}
|
||||
if (isDynamic && node && node.component.constructor !== name) {
|
||||
node = undefined;
|
||||
|
||||
@@ -16,7 +16,12 @@ export function makeRootFiber(node: ComponentNode): Fiber {
|
||||
let current = node.fiber;
|
||||
if (current) {
|
||||
let root = current.root!;
|
||||
// lock root fiber because canceling children fibers may destroy components,
|
||||
// which means any arbitrary code can be run in onWillDestroy, which may
|
||||
// trigger new renderings
|
||||
root.locked = true;
|
||||
root.setCounter(root.counter + 1 - cancelFibers(current.children));
|
||||
root.locked = false;
|
||||
current.children = [];
|
||||
current.childrenMap = {};
|
||||
current.bdom = null;
|
||||
|
||||
Reference in New Issue
Block a user