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; break;
} }
case LFUN_BUFFER_SWITCH: { 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; break;
Buffer * buffer = }
theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
Buffer * buffer = theBufferList().getBuffer(FileName(file_name));
if (!buffer) { if (!buffer) {
dr.setError(true); dr.setError(true);
dr.setMessage(_("Document not loaded")); dr.setMessage(_("Document not loaded"));
break; 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); setBuffer(buffer);
break; break;
} }
// Look for the buffer in other views
QList<int> const ids = guiApp->viewIds(); QList<int> const ids = guiApp->viewIds();
int i = 0; int i = 0;
for (; i != ids.size(); ++i) { for (; i != ids.size(); ++i) {
@ -2973,13 +2982,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break; break;
} }
} }
// If necessary, open a new window as a last resort
if (i == ids.size()) { if (i == ids.size()) {
if (!lyxrc.open_buffers_in_tabs && documentBufferView() != 0) { lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW)); lyx::dispatch(cmd);
lyx::dispatch(cmd);
} else {
setBuffer(buffer);
}
} }
break; break;
} }