OSDN Git Service

disable copying of QTextBoundaryFinderPrivate and do it in QTextBoundaryFinder
authorIvailo Monev <xakepa10@gmail.com>
Sat, 26 Dec 2020 17:22:29 +0000 (17:22 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 26 Dec 2020 17:22:29 +0000 (17:22 +0000)
fixes Kate crashes when attempting to do spelling (spelling from cursor,
selection, etc.)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/tools/qtextboundaryfinder.cpp

index 77f7e10..3260e30 100644 (file)
@@ -69,7 +69,6 @@ class QTextBoundaryFinderPrivate
 public:
     QTextBoundaryFinderPrivate();
     QTextBoundaryFinderPrivate(const QTextBoundaryFinder::BoundaryType type, const QString &text);
-    QTextBoundaryFinderPrivate(const QTextBoundaryFinderPrivate &other);
     ~QTextBoundaryFinderPrivate();
 
     QTextBoundaryFinder::BoundaryType type;
@@ -77,7 +76,8 @@ public:
     QString string;
     mutable UBreakIterator *breakiter; // ubrk_isBoundary() takes non-const argument
 
-    QTextBoundaryFinderPrivate& operator=(const QTextBoundaryFinderPrivate &other);
+private:
+    Q_DISABLE_COPY(QTextBoundaryFinderPrivate);
 };
 
 QTextBoundaryFinderPrivate::QTextBoundaryFinderPrivate()
@@ -99,30 +99,6 @@ QTextBoundaryFinderPrivate::QTextBoundaryFinderPrivate(const QTextBoundaryFinder
     }
 }
 
-QTextBoundaryFinderPrivate::QTextBoundaryFinderPrivate(const QTextBoundaryFinderPrivate &other)
-{
-    QTextBoundaryFinderPrivate::operator=(other);
-}
-
-QTextBoundaryFinderPrivate& QTextBoundaryFinderPrivate::operator=(const QTextBoundaryFinderPrivate &other)
-{
-    type = other.type;
-    pos = other.pos;
-    string = other.string;
-
-    if (breakiter) {
-        ubrk_close(breakiter);
-    }
-
-    UErrorCode error = U_ZERO_ERROR;
-    breakiter = ubrk_safeClone(other.breakiter, Q_NULLPTR, Q_NULLPTR, &error);
-    if (Q_UNLIKELY(U_FAILURE(error))) {
-        qWarning("QTextBoundaryFinder: ubrk_safeClone() failed %s", u_errorName(error));
-        breakiter = Q_NULLPTR;
-    }
-    return *this;
-}
-
 QTextBoundaryFinderPrivate::~QTextBoundaryFinderPrivate()
 {
     if (breakiter) {
@@ -211,7 +187,20 @@ QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)
 */
 QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &other)
 {
-    d = other.d;
+    d->type = other.d->type;
+    d->pos = other.d->pos;
+    d->string = other.d->string;
+
+    if (d->breakiter) {
+        ubrk_close(d->breakiter);
+    }
+
+    UErrorCode error = U_ZERO_ERROR;
+    d->breakiter = ubrk_safeClone(other.d->breakiter, Q_NULLPTR, Q_NULLPTR, &error);
+    if (Q_UNLIKELY(U_FAILURE(error))) {
+        qWarning("QTextBoundaryFinder: ubrk_safeClone() failed %s", u_errorName(error));
+        d->breakiter = Q_NULLPTR;
+    }
     return *this;
 }