Better fix for bug #5942: proper multi-window usage is restored again. Now, LyX only switches to a buffer in a different view if open in tabs is disabled and there is already a document open in the current view and the buffer is already opened in another view.

see r34618.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34684 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-06-17 21:18:08 +00:00
parent e85790c3a3
commit f27ccb580b

View File

@ -2950,19 +2950,28 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
}
case LFUN_BUFFER_SWITCH: {
if (!FileName::isAbsolute(to_utf8(cmd.argument())))
string const file_name = to_utf8(cmd.argument());
if (!FileName::isAbsolute(file_name)) {
dr.setError(true);
dr.setMessage(_("Absolute filename expected."));
break;
Buffer * buffer =
theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
}
Buffer * buffer = theBufferList().getBuffer(FileName(file_name));
if (!buffer) {
dr.setError(true);
dr.setMessage(_("Document not loaded"));
break;
}
if (workArea(*buffer)) {
}
// Do we open or switch to the buffer in this view ?
if (workArea(*buffer)
|| lyxrc.open_buffers_in_tabs || !documentBufferView()) {
setBuffer(buffer);
break;
}
}
// Look for the buffer in other views
QList<int> const ids = guiApp->viewIds();
int i = 0;
for (; i != ids.size(); ++i) {
@ -2973,13 +2982,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
}
}
// If necessary, open a new window as a last resort
if (i == ids.size()) {
if (!lyxrc.open_buffers_in_tabs && documentBufferView() != 0) {
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
lyx::dispatch(cmd);
} else {
setBuffer(buffer);
}
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
lyx::dispatch(cmd);
}
break;
}