Introduce (Inset|InsetList|Paragraph)::resetBuffer

This avoids an ugly cast like
     setBuffer(*static_cast<Buffer *>(0));
that clang does not appreciate.
This commit is contained in:
Jean-Marc Lasgouttes 2016-12-05 14:47:13 +01:00
parent 938e49171b
commit fd50fb720f
7 changed files with 31 additions and 7 deletions

View File

@ -652,7 +652,7 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
// are not linked to something else.
it = copy_pars.begin();
for (; it != it_end; ++it) {
it->setBuffer(*static_cast<Buffer *>(0));
it->resetBuffer();
it->setInsetOwner(0);
}

View File

@ -10,18 +10,15 @@
*/
#include <config.h>
#include <algorithm>
#include "InsetList.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BranchList.h"
#include "insets/InsetBranch.h"
#include "insets/Inset.h"
#include "support/debug.h"
#include <algorithm>
using namespace std;
namespace lyx {
@ -84,6 +81,15 @@ void InsetList::setBuffer(Buffer & b)
}
void InsetList::resetBuffer()
{
List::iterator it = list_.begin();
List::iterator end = list_.end();
for (; it != end; ++it)
it->inset->resetBuffer();
}
InsetList::iterator InsetList::insetIterator(pos_type pos)
{
InsetTable search_elem(pos, 0);

View File

@ -36,6 +36,8 @@ public:
InsetList(InsetList const &, pos_type beg, pos_type end);
///
void setBuffer(Buffer &);
///
void resetBuffer();
///
class InsetTable {

View File

@ -3534,6 +3534,12 @@ void Paragraph::setBuffer(Buffer & b)
}
void Paragraph::resetBuffer()
{
d->insetlist_.resetBuffer();
}
Inset * Paragraph::releaseInset(pos_type pos)
{
Inset * inset = d->insetlist_.release(pos);

View File

@ -396,6 +396,8 @@ public:
InsetList const & insetList() const;
///
void setBuffer(Buffer &);
///
void resetBuffer();
///
bool isHfill(pos_type pos) const;

View File

@ -186,6 +186,12 @@ void Inset::setBuffer(Buffer & buffer)
}
void Inset::resetBuffer()
{
buffer_ = nullptr;
}
Buffer & Inset::buffer()
{
if (!buffer_) {

View File

@ -108,6 +108,8 @@ public:
/// change associated Buffer
virtual void setBuffer(Buffer & buffer);
/// reset associated Buffer to null value
virtual void resetBuffer();
/// retrieve associated Buffer
virtual Buffer & buffer();
virtual Buffer const & buffer() const;