Peter Kümmel wrote:
Abdelrazak Younes wrote:
 > I suggest that you test this carefully before applying. You don't want
to know how much time I spent to get it right on windows.

Do you see/have problems with the attached patch?

Here on windows it works fine. It also removes the
buggy Qt code.

Did you test with multiple windows?

More comment below...

------------------------------------------------------------------------

Index: src/frontends/qt4/GuiImplementation.C
===================================================================
--- src/frontends/qt4/GuiImplementation.C       (revision 15972)
+++ src/frontends/qt4/GuiImplementation.C       (working copy)
@@ -104,9 +104,7 @@
        buildViewIds();
if (views_.empty()) {
-               theLyXFunc().setLyXView(0);
-//             dispatch(FuncRequest(LFUN_LYX_QUIT));
-               return;
+               dispatch(FuncRequest(LFUN_LYX_QUIT, "force"));

I seem to remember that "force" was not doing anything really... not sure about that.

        }
theLyXFunc().setLyXView(views_.begin()->second);
Index: src/frontends/qt4/GuiApplication.C
===================================================================
--- src/frontends/qt4/GuiApplication.C  (revision 15975)
+++ src/frontends/qt4/GuiApplication.C  (working copy)
@@ -159,25 +159,10 @@
        This feature be turned off by setting quitOnLastWindowClosed to false.
        */
        setQuitOnLastWindowClosed(false);
- // this connect should not be necessary: - // we rely on a Qt bug on Windows and maybe Linux
-       QObject::connect(this, SIGNAL(lastWindowClosed()),
-               this, SLOT(quitLyX()));

IIUC, then we rely on Qt behaving correctly on quitOnLastWindowClosed. This was not possible at the time I implement the multi-windows because some things were not destroyed in the correct order. But I have done a lot of cleanup in the LyX class after that so it is quite possible that it is OK now.

guiApp = this;
 }
-
-void GuiApplication::quitLyX()
-{
-       theLyXFunc().setLyXView(0);
-
-       // trigger LFUN_LYX_QUIT instead of QApplication::quit() directly
-       // since LFUN_LYX_QUIT may have more cleanup stuff
-       dispatch(FuncRequest(LFUN_LYX_QUIT, "force"));
-}
-
-
 Clipboard& GuiApplication::clipboard()
 {
        return clipboard_;
Index: src/frontends/qt4/GuiApplication.h
===================================================================
--- src/frontends/qt4/GuiApplication.h  (revision 15972)
+++ src/frontends/qt4/GuiApplication.h  (working copy)
@@ -83,10 +83,6 @@
        ///
        GuiFontLoader & guiFontLoader() { return font_loader_; }
-private Q_SLOTS:
-       /// request an LFUN_LYX_QUIT
-       void quitLyX();
-
 private:
        ///
        GuiImplementation gui_;
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C      (revision 15973)
+++ src/lyx_main.C      (working copy)
@@ -410,15 +410,20 @@
 {
        lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
+ theLyXFunc().setLyXView(0);
+

Yes, maybe a good idea to ensure that.

        prepareExit();
if (use_gui) {
                pimpl_->session_->writeFile();
                pimpl_->lyx_server_.reset();
                pimpl_->lyx_socket_.reset();
+               // this calls Qt's exit which does return
                pimpl_->application_->exit(0);
                theApp = 0;
        }
+       // this is the point of leaving lyx normally
+       ::exit(0);

You should not need to do that explicitily. LyX::exec() will return in main() and that should be the normal exit path.

Abdel.

Reply via email to