]> git.lyx.org Git - features.git/commitdiff
Better fix for bug #5942: proper multi-window usage is restored again. Now, LyX only...
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 17 Jun 2010 21:18:08 +0000 (21:18 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 17 Jun 2010 21:18:08 +0000 (21:18 +0000)
see r34618.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34684 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp

index 37d7cf44372f50770afdbc5e3735248c83421af5..e4e4d39b78ab3804cbebc5da5b2c79bd437aa6f3 100644 (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;
                }