Peter Kümmel wrote:
> Peter Kümmel wrote:
>> Bennett Helm wrote:
>>> On Nov 18, 2006, at 12:50 PM, Abdelrazak Younes wrote:
>>>
>>>> Georg Baum wrote:
>>>>> Am Freitag, 17. November 2006 21:06 schrieb Peter Kümmel:
>>>>>> Georg Baum wrote:
>>>>>>> Peter Kümmel wrote:
>>>>>>>
>>>>>>>> My idea was to use some Loki code for singletons and global static
>>>>> data.
>>>>>>> I don't know Loki, so maybe I am missing something here, but I believe
>>>>> that
>>>>>>> we already have everything needed.
>>>>>> Yes, we have C++.
>>>>> What do you mean? I believe that Loki is a well designed library of
>>>>> good quality, but I do not see the problem that it might solve for
>>>>> us. Our problem is that some global static objects are destructed too
>>>>> late, because they need other objects. This problem can be solved
>>>>> IMHO by putting these objects into the LyX singleton, so I don't see
>>>>> why we need any additional code.
>>>> This is what I did. Hopefully, all crash-on-exit problems on windows
>>>> and Mac should be solved now.
>>> Unfortunately, not. Quitting LyX on Mac gives:
>>>
>>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>>> Reason: KERN_PROTECTION_FAILURE at address: 0x00000040
>>> 0x0008e0a5 in lyx::LyXServerSocket::~LyXServerSocket (this=0xe3c15f0) at
>>> lyxsocket.C:80
>>> 80                      theApp->unregisterSocketCallback(fd_);
>>> (gdb) bt
>>> #0  0x0008e0a5 in lyx::LyXServerSocket::~LyXServerSocket
>>> (this=0xe3c15f0) at lyxsocket.C:80
>>> #1  0x00664e9e in boost::checked_delete<lyx::LyXServerSocket>
>>> (x=0xe3c15f0) at ../boost/boost/checked_delete.hpp:34
>>> #2  0x00065f61 in lyx::LyX::quit (this=0xbffff960) at lyx_main.C:418
>>> #3  0x00066006 in lyx::LyX::~LyX (this=0xbffff960) at lyx_main.C:176
>>> #4  0x00002995 in main (argc=1, argv=0xbffff9ec) at main.C:48
>>>
>>> Bennett
>> void LyX::quit()
>> {
>>      lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
>>
>>      prepareExit();
>>
>>      if (use_gui) {
>>              pimpl_->session_->writeFile();
>>              pimpl_->lyx_server_.reset();
>>              pimpl_->lyx_socket_.reset();
>>              pimpl_->application_->exit(0);
>>      }
>> }

The backtrace says LyX::quit() is called from LyX::~LyX.
But how could it be possible with this function matching
code?

        case LFUN_LYX_QUIT:
                        if (argument != "force") {
                                if (!theApp->gui().closeAll())
                                        break;
                                lyx_view_ = 0;
                        }

                        // 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.
                        if (lyx_view_ && lyx_view_->view()->buffer()) {
                                // save cursor Position for opened files to 
.lyx/session
                                
LyX::ref().session().lastFilePos().save(lyx_view_->buffer()->fileName(),
                                        boost::tie(view()->cursor().pit(), 
view()->cursor().pos()) );
                        }

                        LyX::ref().quit();
                        break;


Seems the quit logic is responsible for the bug, not the destruction order of 
static objects.

Peter

Reply via email to