mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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:
parent
938e49171b
commit
fd50fb720f
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
InsetList(InsetList const &, pos_type beg, pos_type end);
|
||||
///
|
||||
void setBuffer(Buffer &);
|
||||
///
|
||||
void resetBuffer();
|
||||
|
||||
///
|
||||
class InsetTable {
|
||||
|
@ -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);
|
||||
|
@ -396,6 +396,8 @@ public:
|
||||
InsetList const & insetList() const;
|
||||
///
|
||||
void setBuffer(Buffer &);
|
||||
///
|
||||
void resetBuffer();
|
||||
|
||||
///
|
||||
bool isHfill(pos_type pos) const;
|
||||
|
@ -186,6 +186,12 @@ void Inset::setBuffer(Buffer & buffer)
|
||||
}
|
||||
|
||||
|
||||
void Inset::resetBuffer()
|
||||
{
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Buffer & Inset::buffer()
|
||||
{
|
||||
if (!buffer_) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user