mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-02 08:24:14 +02:00
Fix bugtracker #266: undoing a resize to zero width did nothing
Resizing a selection in the element editor down to zero width or height could not be undone: ScalePartsCommand scales back from the new rect, and a flat rect cannot be scaled from, so undo silently left the shapes collapsed and the flattening was saved. The same flat rect made deltaForRoundScaling() divide 0 by 0 and fill the resize rect with NaN. Never commit a resize rect with no width or height, and do not resize a selection that is already flat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -527,6 +527,12 @@ void ElementPrimitiveDecorator::handlerMouseMoveEvent(QetGraphicsHandlerItem *qg
|
||||
{
|
||||
Q_UNUSED(qghi);
|
||||
|
||||
// A selection with no width or height cannot be scaled (see
|
||||
// scaleItems()); resizing it would only record a bogus undo step.
|
||||
if (!original_bounding_rect_.width() || !original_bounding_rect_.height()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPointF scene_pos = event -> scenePos();
|
||||
QPointF movement = scene_pos - latest_pos_;
|
||||
|
||||
@@ -564,8 +570,15 @@ void ElementPrimitiveDecorator::handlerMouseMoveEvent(QetGraphicsHandlerItem *qg
|
||||
movement = rounded_scene_pos - current_position;
|
||||
}
|
||||
|
||||
QRectF scaled_rect = modified_bounding_rect_;
|
||||
applyMovementToRect(current_operation_square_, movement, scaled_rect);
|
||||
// A rect with no width or height cannot be scaled back from, so the
|
||||
// resize could never be undone: keep the last usable size instead.
|
||||
if (!scaled_rect.width() || !scaled_rect.height()) {
|
||||
return;
|
||||
}
|
||||
QRectF bounding_rect = modified_bounding_rect_;
|
||||
applyMovementToRect(current_operation_square_, movement, modified_bounding_rect_);
|
||||
modified_bounding_rect_ = scaled_rect;
|
||||
if (modified_bounding_rect_ != bounding_rect) {
|
||||
adjustEffectiveBoundingRect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user