Commit edb2c841 authored by Tusooa Zhu's avatar Tusooa Zhu 🔼

Fix an assert when cloning perspective assistant

The handles in the variables `topLeft`, `topRight`, etc. are but
duplicates of the ones in the handle list, so they must have been
already registered to the new assistant. Registering them twice
will trigger an assert.

BUG: 409249
parent b7bd264b
......@@ -123,7 +123,7 @@ void KisPaintingAssistantHandle::uncache()
struct KisPaintingAssistant::Private {
Private();
explicit Private(const Private &rhs);
KisPaintingAssistantHandleSP reuseOrCreateHandle(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap, KisPaintingAssistantHandleSP origHandle, KisPaintingAssistant *q);
KisPaintingAssistantHandleSP reuseOrCreateHandle(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap, KisPaintingAssistantHandleSP origHandle, KisPaintingAssistant *q, bool registerAssistant = true);
QList<KisPaintingAssistantHandleSP> handles, sideHandles;
KisPaintingAssistantHandleSP topLeft, bottomLeft, topRight, bottomRight, topMiddle, bottomMiddle, rightMiddle, leftMiddle;
......@@ -166,7 +166,7 @@ KisPaintingAssistant::Private::Private(const Private &rhs)
{
}
KisPaintingAssistantHandleSP KisPaintingAssistant::Private::reuseOrCreateHandle(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap, KisPaintingAssistantHandleSP origHandle, KisPaintingAssistant *q)
KisPaintingAssistantHandleSP KisPaintingAssistant::Private::reuseOrCreateHandle(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap, KisPaintingAssistantHandleSP origHandle, KisPaintingAssistant *q, bool registerAssistant)
{
KisPaintingAssistantHandleSP mappedHandle = handleMap.value(origHandle);
if (!mappedHandle) {
......@@ -181,7 +181,7 @@ KisPaintingAssistantHandleSP KisPaintingAssistant::Private::reuseOrCreateHandle(
mappedHandle = KisPaintingAssistantHandleSP();
}
}
if (mappedHandle) {
if (mappedHandle && registerAssistant) {
mappedHandle->registerAssistant(q);
}
return mappedHandle;
......@@ -235,7 +235,7 @@ KisPaintingAssistant::KisPaintingAssistant(const KisPaintingAssistant &rhs, QMap
Q_FOREACH (const KisPaintingAssistantHandleSP origHandle, rhs.d->sideHandles) {
d->sideHandles << d->reuseOrCreateHandle(handleMap, origHandle, this);
}
#define _REUSE_H(name) d->name = d->reuseOrCreateHandle(handleMap, rhs.d->name, this)
#define _REUSE_H(name) d->name = d->reuseOrCreateHandle(handleMap, rhs.d->name, this, /* registerAssistant = */ false)
_REUSE_H(topLeft);
_REUSE_H(bottomLeft);
_REUSE_H(topRight);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment