Commit 665f9c1e authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XRENDERING-624: Provide a tool to convert a parsed wiki content to inline

* modifying directly the block's children list is not safe
parent e73c33b9
......@@ -184,18 +184,16 @@ public void addChildren(List<? extends Block> blocksToAdd)
@Override
public void setChildren(List<? extends Block> children)
{
if (children != this.childrenBlocks) {
if (children.isEmpty()) {
if (this.childrenBlocks != null) {
this.childrenBlocks.clear();
}
} else {
if (this.childrenBlocks != null) {
this.childrenBlocks.clear();
}
addChildren(children);
if (children.isEmpty()) {
if (this.childrenBlocks != null) {
this.childrenBlocks.clear();
}
} else {
if (this.childrenBlocks != null) {
this.childrenBlocks.clear();
}
addChildren(children);
}
}
......
......@@ -73,12 +73,8 @@ public Block convertToInline(Block rootBlock, boolean preserveXDOM)
{
List<Block> blocks;
if (rootBlock instanceof XDOM || rootBlock instanceof CompositeBlock) {
blocks = rootBlock.getChildren();
// Make sure to the list is modifiable List
if (!(blocks instanceof ArrayList)) {
blocks = new ArrayList<>(blocks);
}
// We can't modify directly the block's children list
blocks = new ArrayList<>(rootBlock.getChildren());
} else {
blocks = Arrays.asList(rootBlock);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment