Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

late night coding fix

  • Loading branch information...
commit 8884a9dd0571775c1a8d1e57ea0300f65f54fc63 1 parent 297e27e
Acerbic authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/dloader/page/AbstractPage.java
View
14 src/dloader/page/AbstractPage.java
@@ -412,12 +412,13 @@ boolean updateFromNet(ProgressReporter reporter) throws ProblemsReadingDocumentE
setTitle(tempPage.getTitle());
// somewhat awkward way to copy custom object data from temp object
readCacheSelf(tempPage.getSpecificDataXML());
-
+
+ // modifying child without locking because child pages are not published yet.
+ for (AbstractPage child: tempPage.childPages)
+ child.parent = this;
+
// lets try to save some existing children for performance
mergeNewChildren(new LinkedList<>(childPages), tempPage.childPages);
-
- for (AbstractPage child: childPages)
- child.parent = this;
}
return true;
}
@@ -429,6 +430,8 @@ boolean updateFromNet(ProgressReporter reporter) throws ProblemsReadingDocumentE
*/
private void mergeNewChildren (Collection<AbstractPage> oldChildren, Collection<AbstractPage> newChildren) {
childPages.clear(); // discard previous data if any.
+ List<AbstractPage> resultChildren = new LinkedList<>();
+
for (AbstractPage newChild: newChildren) {
// search if exactly that child existed.
AbstractPage oldChild = null;
@@ -439,13 +442,12 @@ private void mergeNewChildren (Collection<AbstractPage> oldChildren, Collection<
oldChild = current; break;
}
- List<AbstractPage> resultChildren = new LinkedList<>();
if (oldChild != null) {
resultChildren.add(oldChild);
} else
resultChildren.add(newChild);
- childPages.addAll(resultChildren);
}
+ childPages.addAll(resultChildren); // at this point new children become published, as childPages is of unprotected access
}
/**
* Saves this page data into XML tree.
Please sign in to comment.
Something went wrong with that request. Please try again.