mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
reference count QTextBoundaryFinderPrivate
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
40f9ec5fa6
commit
e4a2aeda4a
1 changed files with 6 additions and 3 deletions
|
@ -75,18 +75,19 @@ public:
|
|||
int pos;
|
||||
QString string;
|
||||
mutable UBreakIterator *breakiter; // ubrk_isBoundary() takes non-const argument
|
||||
QAtomicInt ref;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QTextBoundaryFinderPrivate);
|
||||
};
|
||||
|
||||
QTextBoundaryFinderPrivate::QTextBoundaryFinderPrivate()
|
||||
: type(QTextBoundaryFinder::Grapheme), pos(0), breakiter(Q_NULLPTR)
|
||||
: type(QTextBoundaryFinder::Grapheme), pos(0), breakiter(Q_NULLPTR), ref(1)
|
||||
{
|
||||
}
|
||||
|
||||
QTextBoundaryFinderPrivate::QTextBoundaryFinderPrivate(const QTextBoundaryFinder::BoundaryType type, const QString &text)
|
||||
: type(type), pos(0), string(text), breakiter(Q_NULLPTR)
|
||||
: type(type), pos(0), string(text), breakiter(Q_NULLPTR), ref(1)
|
||||
{
|
||||
if (Q_LIKELY(!string.isEmpty())) {
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
|
@ -180,6 +181,7 @@ QTextBoundaryFinder::QTextBoundaryFinder()
|
|||
QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)
|
||||
: d(other.d)
|
||||
{
|
||||
d->ref.ref();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -209,7 +211,8 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o
|
|||
*/
|
||||
QTextBoundaryFinder::~QTextBoundaryFinder()
|
||||
{
|
||||
delete d;
|
||||
if (!d->ref.deref())
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Add table
Reference in a new issue