mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-26 03:44:14 +02:00
Compare commits
4 Commits
e47dcec7cb
...
899f10533d
| Author | SHA1 | Date | |
|---|---|---|---|
| 899f10533d | |||
| 5b2fdaeb00 | |||
| 5027ffda9b | |||
| 3ca5d4ab29 |
@@ -20,6 +20,7 @@ All notable changes to QElectroTech are documented here.
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- Fix #798: clamp element-editor and diagram-view zoom to prevent view-transform overflow crash on scroll-wheel zoom ([3ca5d4a](../../commit/3ca5d4ab2))
|
||||
- Fix(windows-msi): inject rev into MSI Version Build field ([e19f523](../../commit/e19f5232277efb37435cb65a83563d73333d62ec))
|
||||
- Fix #391: use wide-char path for pugixml on Windows to handle Unicode paths ([31edf30](../../commit/31edf30c619213368e9b592b51be6ca8190db831))
|
||||
- Fix(#283): restore center alignment when loading table config ([f55ba56](../../commit/f55ba568f68293e06436899bcc831431e9d27295))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -100,13 +100,30 @@ void ElementView::setSelectionMode()
|
||||
emit(modeChanged());
|
||||
}
|
||||
|
||||
/**
|
||||
Applique un facteur d'echelle a la vue en bornant l'echelle resultante
|
||||
entre m_min_zoom et m_max_zoom. Sans cette borne, un zoom repete (molette)
|
||||
finit par faire deborder la transformation de la vue et fait planter
|
||||
l'editeur (issue #798).
|
||||
@param factor facteur d'echelle a appliquer
|
||||
*/
|
||||
void ElementView::scaleClamped(qreal factor)
|
||||
{
|
||||
const qreal current = transform().m11();
|
||||
const qreal target = current * factor;
|
||||
if (target < m_min_zoom || target > m_max_zoom) {
|
||||
return;
|
||||
}
|
||||
scale(factor, factor);
|
||||
}
|
||||
|
||||
/**
|
||||
Agrandit le schema (+33% = inverse des -25 % de zoomMoins())
|
||||
*/
|
||||
void ElementView::zoomIn()
|
||||
{
|
||||
adjustSceneRect();
|
||||
scale(4.0/3.0, 4.0/3.0);
|
||||
scaleClamped(4.0/3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +132,7 @@ void ElementView::zoomIn()
|
||||
void ElementView::zoomOut()
|
||||
{
|
||||
adjustSceneRect();
|
||||
scale(0.75, 0.75);
|
||||
scaleClamped(0.75);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +140,7 @@ void ElementView::zoomOut()
|
||||
*/
|
||||
void ElementView::zoomInSlowly()
|
||||
{
|
||||
scale(1.02, 1.02);
|
||||
scaleClamped(1.02);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +148,7 @@ void ElementView::zoomInSlowly()
|
||||
*/
|
||||
void ElementView::zoomOutSlowly()
|
||||
{
|
||||
scale(0.98, 0.98);
|
||||
scaleClamped(0.98);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,6 +53,13 @@ class ElementView : public QGraphicsView {
|
||||
|
||||
private:
|
||||
QRectF applyMovement(const QRectF &, const QPointF &);
|
||||
void scaleClamped(qreal factor);
|
||||
|
||||
/// Lowest and highest allowed value of the view transform scale (m11).
|
||||
/// Prevents the wheel-zoom from driving the transform to overflow, which
|
||||
/// crashes the editor (bugtracker / GitHub issue #798).
|
||||
static constexpr qreal m_min_zoom = 0.1;
|
||||
static constexpr qreal m_max_zoom = 200.0;
|
||||
|
||||
public slots:
|
||||
void setVisualisationMode();
|
||||
|
||||
Reference in New Issue
Block a user