mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Fix bug 4096. Don't disconnect the buffer until we're ready to connect again.
Also, clean up the code a little. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@19288 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
37f4a3dad1
commit
02fb80e579
@ -143,7 +143,7 @@ Buffer * BufferView::buffer() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::setBuffer(Buffer * b)
|
Buffer * BufferView::setBuffer(Buffer * b)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
|
LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
|
||||||
<< "[ b = " << b << "]" << endl;
|
<< "[ b = " << b << "]" << endl;
|
||||||
@ -182,7 +182,7 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
// If we're quitting lyx, don't bother updating stuff
|
// If we're quitting lyx, don't bother updating stuff
|
||||||
if (quitting) {
|
if (quitting) {
|
||||||
buffer_ = 0;
|
buffer_ = 0;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME Fix for bug 3440 is here.
|
//FIXME Fix for bug 3440 is here.
|
||||||
@ -209,7 +209,7 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
offset_ref_ = 0;
|
offset_ref_ = 0;
|
||||||
|
|
||||||
if (!buffer_)
|
if (!buffer_)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
|
LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
|
||||||
<< "Buffer addr: " << buffer_ << endl;
|
<< "Buffer addr: " << buffer_ << endl;
|
||||||
@ -243,6 +243,7 @@ void BufferView::setBuffer(Buffer * b)
|
|||||||
|
|
||||||
if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
|
if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
|
||||||
graphics::Previews::get().generateBufferPreviews(*buffer_);
|
graphics::Previews::get().generateBufferPreviews(*buffer_);
|
||||||
|
return buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ public:
|
|||||||
/// set the buffer we are viewing.
|
/// set the buffer we are viewing.
|
||||||
/// \todo FIXME: eventually, we will create a new BufferView
|
/// \todo FIXME: eventually, we will create a new BufferView
|
||||||
/// when switching Buffers, so this method should go.
|
/// when switching Buffers, so this method should go.
|
||||||
void setBuffer(Buffer * b);
|
/// returns the buffer currently set
|
||||||
|
Buffer * setBuffer(Buffer * b);
|
||||||
/// return the buffer being viewed.
|
/// return the buffer being viewed.
|
||||||
Buffer * buffer() const;
|
Buffer * buffer() const;
|
||||||
|
|
||||||
|
@ -133,20 +133,21 @@ void LyXView::setBuffer(Buffer * b, bool child_document)
|
|||||||
// parentfilename will be used in case when we switch to a child
|
// parentfilename will be used in case when we switch to a child
|
||||||
// document (hence when child_document is true)
|
// document (hence when child_document is true)
|
||||||
string parentfilename;
|
string parentfilename;
|
||||||
if (oldBuffer) {
|
if (oldBuffer)
|
||||||
parentfilename = oldBuffer->fileName();
|
parentfilename = oldBuffer->fileName();
|
||||||
disconnectBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!b && theBufferList().empty())
|
if (!b && theBufferList().empty())
|
||||||
getDialogs().hideBufferDependent();
|
getDialogs().hideBufferDependent();
|
||||||
|
|
||||||
work_area_->bufferView().setBuffer(b);
|
Buffer * newBuffer = work_area_->bufferView().setBuffer(b);
|
||||||
|
|
||||||
//FIXME This would be a little simpler if setBuffer returned the buffer.
|
|
||||||
Buffer * newBuffer = work_area_->bufferView().buffer();
|
|
||||||
if (newBuffer) {
|
if (newBuffer) {
|
||||||
if (child_document && newBuffer->getMasterBuffer() != oldBuffer) {
|
//Are we closing an oldBuffer which was a child document?
|
||||||
|
if (!b && oldBuffer && oldBuffer->getMasterBuffer() != oldBuffer)
|
||||||
|
// Update the labels and section numbering of its master Buffer.
|
||||||
|
updateLabels(*oldBuffer->getMasterBuffer());
|
||||||
|
//Are we opening a new child document?
|
||||||
|
else if (child_document && newBuffer->getMasterBuffer() != oldBuffer) {
|
||||||
// Set the parent name of the child document.
|
// Set the parent name of the child document.
|
||||||
// This makes insertion of citations and references in the child work,
|
// This makes insertion of citations and references in the child work,
|
||||||
// when the target is in the parent or another child document.
|
// when the target is in the parent or another child document.
|
||||||
@ -154,13 +155,11 @@ void LyXView::setBuffer(Buffer * b, bool child_document)
|
|||||||
// Update the labels and section numbering to the new master Buffer.
|
// Update the labels and section numbering to the new master Buffer.
|
||||||
updateLabels(*newBuffer->getMasterBuffer());
|
updateLabels(*newBuffer->getMasterBuffer());
|
||||||
}
|
}
|
||||||
|
//Now that all the updating of the old buffer has been done, we can
|
||||||
if (!b && oldBuffer && oldBuffer->getMasterBuffer() != oldBuffer)
|
//connect the new buffer. Note that this will also disconnect the old
|
||||||
// We are closing oldBuffer which was a child document so we
|
//buffer, if such there is.
|
||||||
// must update the labels and section numbering of its master
|
//FIXME Is it clear that this should go right here? Or should it go
|
||||||
// Buffer.
|
//earlier before the previous if (in which case we'd remove the "else")?
|
||||||
updateLabels(*oldBuffer->getMasterBuffer());
|
|
||||||
|
|
||||||
connectBuffer(*newBuffer);
|
connectBuffer(*newBuffer);
|
||||||
|
|
||||||
/* FIXME: We need to rebuild the Toc dialog before the others even
|
/* FIXME: We need to rebuild the Toc dialog before the others even
|
||||||
@ -178,7 +177,9 @@ void LyXView::setBuffer(Buffer * b, bool child_document)
|
|||||||
// hidden. This should go here because some dialogs (eg ToC)
|
// hidden. This should go here because some dialogs (eg ToC)
|
||||||
// require bv_->text.
|
// require bv_->text.
|
||||||
getDialogs().updateBufferDependent(true);
|
getDialogs().updateBufferDependent(true);
|
||||||
}
|
} else
|
||||||
|
//Disconnect the old buffer...there's no new one.
|
||||||
|
disconnectBuffer();
|
||||||
|
|
||||||
if (quitting)
|
if (quitting)
|
||||||
return;
|
return;
|
||||||
|
@ -254,6 +254,12 @@ private:
|
|||||||
/// connect to signals in the given buffer
|
/// connect to signals in the given buffer
|
||||||
void connectBuffer(Buffer & buf);
|
void connectBuffer(Buffer & buf);
|
||||||
/// disconnect from signals in the given buffer
|
/// disconnect from signals in the given buffer
|
||||||
|
/// NOTE: Do not call this unless you really want no buffer
|
||||||
|
/// to be connected---for example, when closing the last open
|
||||||
|
/// buffer. If you are switching buffers, just call
|
||||||
|
/// connectBuffer(), and the old buffer will be disconnected
|
||||||
|
/// automatically. This ensures that we do not leave LyX in a
|
||||||
|
/// state in which no buffer is connected.
|
||||||
void disconnectBuffer();
|
void disconnectBuffer();
|
||||||
|
|
||||||
/// BufferView messages signal connection
|
/// BufferView messages signal connection
|
||||||
|
Loading…
Reference in New Issue
Block a user