From: Alfredo Braunstein Date: Fri, 11 Jul 2003 12:21:31 +0000 (+0000) Subject: fixes buffer closing crashes X-Git-Tag: 1.6.10~16555 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dcb9c3eabb55a987f11eb52967ab7845583e75db;p=features.git fixes buffer closing crashes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7267 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 960389188d..3d89894972 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -156,6 +156,7 @@ void BufferView::Pimpl::connectBuffer(Buffer & buf) 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(); } diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 1e9c7fc297..b98a01ecc2 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -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 diff --git a/src/ChangeLog b/src/ChangeLog index 734c43f03b..7c5303f828 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,11 @@ -2003-07-10 Alfredo Brauntein +2003-07-11 Alfredo Braunstein + + * buffer.[Ch]: added new closing signal + * BufferView_pimpl.[Ch]: connect/disconnect to new signal + * lyxfunc.C: removed BufferView::buffer(0) call now handled in + BufferView::Pimpl via the closing the signal + +2003-07-10 Alfredo Braunstein * buffer.[Ch]: take out all bv-related from buffer * BufferView.C: diff --git a/src/buffer.C b/src/buffer.C index 1ee9bd945b..1f1a39945e 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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)); diff --git a/src/buffer.h b/src/buffer.h index 4977513afe..26abfd024a 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -117,6 +117,8 @@ public: boost::signal0 updateTitles; /// Reset autosave timers for all users. boost::signal0 resetAutosaveTimers; + /// This signal is emitting if the buffer is being closed. + boost::signal0 closing; /** Save file. diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 7aa4c0d6cf..96e6e86acd 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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 {