fix: merge two strokecanvas into one + better cursorShape and pointer handling
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 8s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 28s
Rust / build (pull_request) Successful in 47s
Python / verify (pull_request) Successful in 1m34s
Rust / fmt (pull_request) Successful in 35s
Rust / clippy (pull_request) Successful in 1m0s
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 8s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 28s
Rust / build (pull_request) Successful in 47s
Python / verify (pull_request) Successful in 1m34s
Rust / fmt (pull_request) Successful in 35s
Rust / clippy (pull_request) Successful in 1m0s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "strokecanvasrenderer.hpp"
|
||||
#include "strokecanvasitem.hpp"
|
||||
#include <qcolor.h>
|
||||
#include <QSet>
|
||||
|
||||
namespace ZShell::internal {
|
||||
|
||||
@@ -148,14 +149,27 @@ void StrokeCanvasRenderer::synchronizeData(QCanvasPainterItem* item) {
|
||||
m_penColor = canvas->m_penColor;
|
||||
m_penWidth = canvas->m_penWidth;
|
||||
|
||||
while (m_strokes.size() < canvas->m_strokes.size())
|
||||
m_strokes.append(canvas->m_strokes[m_strokes.size()]);
|
||||
// Detect removed strokes: present in renderer but no longer in canvas
|
||||
QSet<int> canvasGroupIds;
|
||||
for (const auto& stroke : canvas->m_strokes)
|
||||
canvasGroupIds.insert(stroke.groupId);
|
||||
|
||||
if (canvas->m_strokes.isEmpty() && !m_strokes.isEmpty()) {
|
||||
for (const auto& stroke : m_strokes)
|
||||
if (stroke.groupId >= 0)
|
||||
m_pendingGroupRemovals.append(stroke.groupId);
|
||||
m_strokes.clear();
|
||||
for (int i = m_strokes.size() - 1; i >= 0; --i) {
|
||||
if (!canvasGroupIds.contains(m_strokes[i].groupId)) {
|
||||
if (m_strokes[i].groupId >= 0)
|
||||
m_pendingGroupRemovals.append(m_strokes[i].groupId);
|
||||
m_strokes.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Detect added strokes: present in canvas but not yet in renderer
|
||||
QSet<int> rendererGroupIds;
|
||||
for (const auto& stroke : m_strokes)
|
||||
rendererGroupIds.insert(stroke.groupId);
|
||||
|
||||
for (const auto& stroke : canvas->m_strokes) {
|
||||
if (!rendererGroupIds.contains(stroke.groupId))
|
||||
m_strokes.append(stroke);
|
||||
}
|
||||
|
||||
m_currentStroke = canvas->m_currentStroke;
|
||||
|
||||
Reference in New Issue
Block a user