Lars Gullik Bjønnes wrote:

> Please hold all patches until these crashes are fixed.

Can I commit this? Solves both crashes. Note that I don't like it very much,
I would prefer the call to BufferView::buffer(0) to be done from the
'client' side, after destroying the buffer. But on the currect state of
things, I think it's acceptable (not worse than before at least).

Alfredo


Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.390
diff -u -p -u -r1.390 BufferView_pimpl.C
--- BufferView_pimpl.C  10 Jul 2003 13:21:44 -0000      1.390
+++ BufferView_pimpl.C  11 Jul 2003 10:38:03 -0000
@@ -156,6 +156,7 @@ void BufferView::Pimpl::connectBuffer(Bu
        titleConnection_ =
buf.updateTitles.connect(boost::bind(&LyXView::updateWindowTitle, owner_));
        timerConnection_ =
buf.resetAutosaveTimers.connect(boost::bind(&LyXView::resetAutosaveTimer,
owner_));
        readonlyConnection_ =
buf.readonly.connect(boost::bind(&BufferView::Pimpl::showReadonly, this,
_1));
+       closingConnection_ =
buf.closing.connect(boost::bind(&BufferView::Pimpl::buffer, this, (Buffer
*)0));
 }
 
 
@@ -167,6 +168,7 @@ void BufferView::Pimpl::disconnectBuffer
        titleConnection_.disconnect();
        timerConnection_.disconnect();
        readonlyConnection_.disconnect();
+       closingConnection_.disconnect();
 }
 
 
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.92
diff -u -p -u -r1.92 BufferView_pimpl.h
--- BufferView_pimpl.h  10 Jul 2003 12:26:32 -0000      1.92
+++ BufferView_pimpl.h  11 Jul 2003 10:38:03 -0000
@@ -125,6 +125,8 @@ private:
        boost::signals::connection timerConnection_;
        /// buffer readonly status changed signal connection
        boost::signals::connection readonlyConnection_;
+       /// buffer closing signal connection
+       boost::signals::connection closingConnection_;
        /// connect to signals in the given buffer
        void connectBuffer(Buffer & buf);
        /// disconnect from signals in the given buffer
Index: buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.492
diff -u -p -u -r1.492 buffer.C
--- buffer.C    10 Jul 2003 12:26:34 -0000      1.492
+++ buffer.C    11 Jul 2003 10:38:06 -0000
@@ -145,6 +145,8 @@ Buffer::~Buffer()
        // here the buffer should take care that it is
        // saved properly, before it goes into the void.
 
+       closing();
+
        if (!tmppath.empty() && destroyDir(tmppath) != 0) {
                Alert::warning(_("Could not remove temporary directory"),
                        bformat(_("Could not remove the temporary directory %1$s"), 
tmppath));
Index: buffer.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.h,v
retrieving revision 1.148
diff -u -p -u -r1.148 buffer.h
--- buffer.h    10 Jul 2003 12:26:34 -0000      1.148
+++ buffer.h    11 Jul 2003 10:38:07 -0000
@@ -117,6 +117,8 @@ public:
        boost::signal0<void> updateTitles;
        /// Reset autosave timers for all users.
        boost::signal0<void> resetAutosaveTimers;
+       /// This signal is emitting if the buffer is being closed.
+       boost::signal0<void> closing;
 
 
        /** Save file.
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.461
diff -u -p -u -r1.461 lyxfunc.C
--- lyxfunc.C   10 Jul 2003 12:26:35 -0000      1.461
+++ lyxfunc.C   11 Jul 2003 10:38:09 -0000
@@ -1909,9 +1909,8 @@ void LyXFunc::closeBuffer()
 {
        if (bufferlist.close(owner->buffer(), true) && !quitting) {
                if (bufferlist.empty()) {
-                       view()->buffer(0);
-                       // need this otherwise SEGV may occur while trying to
-                       // set variables that don't exist
+                       // need this otherwise SEGV may occur while 
+                       // trying to set variables that don't exist
                        // since there's no current buffer
                        owner->getDialogs().hideBufferDependent();
                } else {


Reply via email to