Abdelrazak Younes wrote:
> 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?
>
Yes, but it works as expected,
it only quits if views_.empty() is true.
> 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.
case LFUN_LYX_QUIT:
if (argument != "force") {
if (!theApp->gui().closeAll())
break;
lyx_view_ = 0;
}
didn't know what it is good for.
Seems this code is never used. LFUN_LYX_QUIT, is only called in:
guiImplementation.C(107): dispatch(FuncRequest(LFUN_LYX_QUIT,
"force"));
>> }
>>
>> 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.
I use Qt 4.2.1. and it works on Windows. On Mac, too, but I don't know the
Qt version Bennett is using, wasn't it also 4.2.1?
I'll test it under Linux.
>>
>> 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.
effectively it was only a code moving.
>
>> 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.
without the exit(0) you go back into some Qt-event-handling code
and you will get a crashes, so exit(0) is necessary at this place.
But this could also be a sign that something is wrong in the code.
Peter