From 5027ffda9bbdd7adeafb8c9809064bc6496b49ac Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 31 Aug 2026 05:47:04 +1200 Subject: [PATCH] Apply the same zoom clamp to DiagramView::zoom() DiagramView::zoom() had the same unbounded scale() as the element editor: a held scroll-wheel zoom could overflow the view transform. Clamp the resulting scale to [m_min_zoom, m_max_zoom] before applying it. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HdWpDp3TrPKbHnv7YUcNJj --- sources/diagramview.cpp | 7 +++++++ sources/diagramview.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 5bef9e088..548da5acc 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -334,6 +334,13 @@ void DiagramView::setSelectionMode() */ void DiagramView::zoom(const qreal zoom_factor) { + // clamp the resulting scale so a repeated wheel-zoom cannot drive the view + // transform to floating-point overflow and crash the editor (issue #798) + const qreal target = transform().m11() * zoom_factor; + if (target < m_min_zoom || target > m_max_zoom) { + return; + } + if (zoom_factor >= 1){ scale(zoom_factor, zoom_factor); } diff --git a/sources/diagramview.h b/sources/diagramview.h index 5f87227f3..ae8933660 100644 --- a/sources/diagramview.h +++ b/sources/diagramview.h @@ -103,6 +103,12 @@ class DiagramView : public QGraphicsView bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const; bool gestures() const; + /// Lowest and highest allowed value of the view transform scale (m11). + /// Prevents wheel-zoom from driving the transform to overflow, which + /// crashes the editor (see GitHub issue #798, same class of bug). + static constexpr qreal m_min_zoom = 0.01; + static constexpr qreal m_max_zoom = 200.0; + signals: /// Signal emitted after the selection mode changed void modeChanged();