Abdelrazak Younes wrote:
> Peter Kümmel wrote:
>>>> I've found a solution without ::exit(0) which I've tested with
>>>> msvc/Qt4.2.1
>>>> and Linux/Qt4.1.3.
>>> I don't understand. Current svn doesn't need the ::exit(0) on Linux and
>>> Windows, so why is it a solution?
>>
>> It is a solution because it doesn't need
>>     QObject::connect(this, SIGNAL(lastWindowClosed()),this,
>> SLOT(quitLyX()));
>> any more, which does not work on the Mac and which should not work on
>> Windows/Linux due to the Qt docs.
>>
>> And if the signal lastWindowClosed() gets supprest in future versions
>> of Qt
>> we have the problems the Mac has also on Linux/Windows: quitLyX will be
>> never called.
> 
> Now that I read again my code (sic), I think you're right. So I'll let
> you handle this from now on, you obviously know what you are talking
> about ;-)
> 
> Abdel.
> 

Trolltech says lastWindowClosed() will be never suppressed.
So the docs are not clear at this point; and that they
could not reproduce the bug (they always get the lastWindowClosed
signal).

Anyway I think it is best to use one exit strategy on all systems,
and wanna apply the attached patch. Maybe it also works onthe Mac
and if not we could still addd a hard ::exit(0).


-- 
Peter Kümmel
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (revision 16027)
+++ src/lyxfunc.C       (working copy)
@@ -1035,7 +1035,7 @@
                        break;
 
                case LFUN_LYX_QUIT:
-                       if (argument != "force") {
+                       if (argument == "closeOnly") {
                                if (!theApp->gui().closeAll())
                                        break;
                                lyx_view_ = 0;
Index: src/frontends/qt4/GuiImplementation.C
===================================================================
--- src/frontends/qt4/GuiImplementation.C       (revision 16027)
+++ src/frontends/qt4/GuiImplementation.C       (working copy)
@@ -57,6 +57,7 @@
 
 bool GuiImplementation::closeAll()
 {
+       // ATM never used
        if (!theBufferList().quitWriteAll())
                return false;
 
@@ -105,7 +106,7 @@
 
        if (views_.empty()) {
                theLyXFunc().setLyXView(0);
-//             dispatch(FuncRequest(LFUN_LYX_QUIT));
+               dispatch(FuncRequest(LFUN_LYX_QUIT));
                return;
        }
 
Index: src/frontends/qt4/GuiWorkArea.C
===================================================================
--- src/frontends/qt4/GuiWorkArea.C     (revision 16027)
+++ src/frontends/qt4/GuiWorkArea.C     (working copy)
@@ -271,7 +271,7 @@
 void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
 {
        // No need to do anything if we didn't change views...
-       if (&lyx_view_ == &theApp->currentView())
+       if (theApp == 0 || &lyx_view_ == &theApp->currentView())
                return;
 
        theApp->setCurrentView(lyx_view_);
@@ -528,7 +528,7 @@
 
        //if (!lyxrc.show_banner)
        //      return;
-       lyxerr << "show banner: " << lyxrc.show_banner << endl;
+       lyxerr[Debug::GUI] << "show banner: " << lyxrc.show_banner << endl;
        /// The text to be written on top of the pixmap
        QString const text = lyx_version ? QString(lyx_version) : qt_("unknown 
version");
        string const file = support::libFileSearch("images", "banner", "ppm");
@@ -583,7 +583,7 @@
        QLPainter pain(&screen_);
 
        if (greyed_out_) {
-               lyxerr << "splash screen requested" << endl;
+               lyxerr[Debug::GUI] << "splash screen requested" << endl;
                doGreyOut(pain);
                verticalScrollBar()->hide();
                update(0, 0, width(), height());
Index: src/frontends/qt4/GuiApplication.C
===================================================================
--- src/frontends/qt4/GuiApplication.C  (revision 16027)
+++ src/frontends/qt4/GuiApplication.C  (working copy)
@@ -152,32 +152,9 @@
 
        LoaderQueue::setPriority(10,100);
 
-       /* Qt Docs:
-       void QApplication::lastWindowClosed ()   [signal]
-       This signal is emitted from QApplication::exec() when the last visible 
-       primary window ... is closed.
-       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()));
-
        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 16027)
+++ 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/frontends/qt4/GuiView.C
===================================================================
--- src/frontends/qt4/GuiView.C (revision 16027)
+++ src/frontends/qt4/GuiView.C (working copy)
@@ -110,9 +110,6 @@
 GuiView::GuiView(int id)
        : QMainWindow(), LyXView(id), commandbuffer_(0), d(*new GuiViewPrivate)
 {
-       setAttribute(Qt::WA_DeleteOnClose, true);
-       setAttribute(Qt::WA_QuitOnClose, true);
-
 //     setToolButtonStyle(Qt::ToolButtonIconOnly);
 //     setIconSize(QSize(12,12));
 
@@ -476,7 +473,8 @@
        }
 
        saveGeometry();
-       gui.unregisterView(this);
+       hide(); // don't remove this hide, it prevents a crash on exit
+       gui.unregisterView(this);       
 }
 
 

Reply via email to