- string const parentfilename = lyx_view_->buffer()->fileName();
- if (theBufferList().exists(filename.absFilename()))
- lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename()));
- else
- if (lyx_view_->loadLyXFile(filename)) {
- // Set the parent name of the child document.
- // This makes insertion of citations and references in the child work,
- // when the target is in the parent or another child document.
- lyx_view_->buffer()->setParentName(parentfilename);
- setMessage(bformat(_("Opening child document %1$s..."),
- makeDisplayPath(filename.absFilename())));
- } else
- setMessage(_("Document not loaded."));
+ if (theBufferList().exists(filename.absFilename())) {
+ Buffer * buf = theBufferList().getBuffer(filename.absFilename());
+ if (!autoOpen)
+ lyx_view_->setBuffer(buf, true);
+ else
+ buf->setParentName(lyx_view_->buffer()->fileName());
+ } else
+ lyx_view_->loadLyXFile(filename, true, true, autoOpen);
+
+ // If a screen update is required (in case where auto_open is false),
+ // loadLyXFile() would have taken care of it already. Otherwise we shall
+ // reset the update flag because it can cause a circular problem.
+ // See bug 3970.
+ updateFlags = Update::None;