Bennett Helm wrote:
> On Dec 2, 2006, at 12:53 PM, Peter Kümmel wrote:
> 
>> Bennett Helm wrote:
>>>> Yes, please this one.
>>>
>>> Well ... I don't notice any difference from the last patch -- including
>>> no crashes to generate a backtrace with.
>>>
>>> Bennett
>>
>> How many ways are there on the Mac to exit the application?
> 
> For proper Mac applications, especially those with text windows, there
> are two ways: <Cmd>-q and LyX > Quit. Some applications (including LyX),
> clicking on the red "stoplight" button -- which is supposed to close the
> window -- will quit the application; this is true of LyX as well
> (because it only uses one window).
> 
>> What is the output of LyX when you apply attached patch
>> for all the ways of exiting?
> 
> 1. <Cmd>-q:
> 
> Program exited normally.
> 
> 2. LyX > Quit:
> 
> Program exited normally.
> 

OK, 1. and 2. shows clearly the problem: no function is
called which we need to save the session & co.

> 3. Red stoplight:
> 
> void GuiView::closeEvent(QCloseEvent * close_event)
> 
> Program exited normally.
> 
> 
> Bennett
> 
> 

I assume "LyX > Quit" is a menu with the entry Quit.

So here a new patch.



-- 
Peter Kümmel
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C       (Revision 16135)
+++ src/lyxfunc.C       (Arbeitskopie)
@@ -1034,6 +1034,7 @@
                        break;
 
                case LFUN_LYX_QUIT:
+                       printf("case LFUN_LYX_QUIT:\n");
                        // FIXME: this code needs to be transfered somewhere 
else
                        // as lyx_view_ will most certainly be null and a same 
buffer
                        // might be visible in more than one LyXView.
@@ -1664,6 +1665,7 @@
                        break;
 
                case LFUN_WINDOW_CLOSE:
+                       printf("case LFUN_WINDOW_CLOSE:\n");
                        BOOST_ASSERT(lyx_view_);
                        BOOST_ASSERT(theApp());
                        lyx_view_->close();
Index: src/frontends/qt4/GuiView.h
===================================================================
--- src/frontends/qt4/GuiView.h (Revision 16133)
+++ src/frontends/qt4/GuiView.h (Arbeitskopie)
@@ -103,6 +103,8 @@
        void normalSizedIcons();
        void bigSizedIcons();
 
+       void macQuit();
+
 protected:
        /// make sure we quit cleanly
        virtual void closeEvent(QCloseEvent * e);
Index: src/frontends/qt4/GuiView.C
===================================================================
--- src/frontends/qt4/GuiView.C (Revision 16135)
+++ src/frontends/qt4/GuiView.C (Arbeitskopie)
@@ -186,6 +186,7 @@
 
 void GuiView::close()
 {
+       printf("void GuiView::close()\n");
        QMainWindow::close();
 }
 
@@ -214,10 +215,30 @@
        updateToolbars();
        updateLayoutChoice();
        updateMenubar();
+
+#ifdef Q_WS_MACX
+       // Qt docs:
+       // "quit or exit        Application Menu | Quit <application name>      
+       // If this entry is not found a default Quit item will be created to 
call
+       // QApplication::quit()"
+       QMenu * lyxMenu =  menuBar()->addMenu("&LyX");
+       QAction * quitAct = new QAction(tr("&Quit"), this);
+       lyxMenu->addAction(quitAct);
+       connect(quitAct, SIGNAL(triggered()),this, SLOT(macQuit()));
+#endif
+
 }
 
+
+void GuiView::macQuit()
+{
+       dispatch(FuncRequest(LFUN_LYX_QUIT));
+}
+
+
 void GuiView::closeEvent(QCloseEvent * close_event)
 {
+       printf("void GuiView::closeEvent(QCloseEvent * close_event)\n");
        theApp()->gui().unregisterView(id());   
        if (theApp()->gui().viewIds().empty())
        {

Reply via email to