Summary: | Crash when selecting cell after creating a chart | ||
---|---|---|---|
Product: | [Applications] calligrasheets | Reporter: | Inge Wallin <inge> |
Component: | general | Assignee: | Sebastian Sauer <sebsauer> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | sebsauer |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Inge Wallin
2011-08-12 10:34:17 UTC
Can still reproduce. Following patch shows the problem; diff --git a/tables/ui/DragAndDropStrategy.cpp b/tables/ui/DragAndDropStrategy.cpp index f500b5a..5f1222c 100644 --- a/tables/ui/DragAndDropStrategy.cpp +++ b/tables/ui/DragAndDropStrategy.cpp @@ -60,6 +60,8 @@ DragAndDropStrategy::DragAndDropStrategy(CellToolBase *cellTool, const KoShape *shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, 0.0)); + Q_ASSERT_X(position.y() >= 0., __FUNCTION__, QString("%1 ouf of bounds, documentPos=%2, shapePos=%3").arg(position.y()).arg(documentPos.y()).arg(shape ? shape->position().y() : 0.0).toLocal8Bit()); + // In which cell did the user click? qreal xpos; qreal ypos; So, the logic to substract the shape's position from the absolute coordinates to reach relative coordinates is broken and produces invalid values. Following patch fixes it and some similar cases. But before we can apply I need to test more why this changed / doesn't provide the expected results any longer and if it's really a proper fix or breaks things at other situations. diff --git a/tables/ui/AbstractSelectionStrategy.cpp b/tables/ui/AbstractSelectionStrategy.cpp index f5982f9..88e5613 100644 --- a/tables/ui/AbstractSelectionStrategy.cpp +++ b/tables/ui/AbstractSelectionStrategy.cpp @@ -59,7 +59,7 @@ void AbstractSelectionStrategy::handleMouseMove(const QPointF& documentPos, Qt:: Q_UNUSED(modifiers) Selection *const selection = d->cellTool->selection(); const KoShape* shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); - const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, 0.0)); + const QPointF position = documentPos /*- (shape ? shape->position() : QPointF(0.0, 0.0))*/; // In which cell did the user click? qreal xpos; qreal ypos; diff --git a/tables/ui/DragAndDropStrategy.cpp b/tables/ui/DragAndDropStrategy.cpp index f500b5a..ad1fb98 100644 --- a/tables/ui/DragAndDropStrategy.cpp +++ b/tables/ui/DragAndDropStrategy.cpp @@ -58,7 +58,7 @@ DragAndDropStrategy::DragAndDropStrategy(CellToolBase *cellTool, d->lastPoint = documentPos; Selection *const selection = this->selection(); const KoShape *shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); - const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, 0.0)); + const QPointF position = documentPos /*+ (shape ? shape->position() : QPointF(0.0, 0.0))*/; // In which cell did the user click? qreal xpos; @@ -85,7 +85,7 @@ void DragAndDropStrategy::handleMouseMove(const QPointF& documentPos, Qt::Keyboa return; d->lastPoint = documentPos; const KoShape *shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); - const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, 0.0)); + const QPointF position = documentPos /*- (shape ? shape->position() : QPointF(0.0, 0.0))*/; // In which cell did the user click? qreal xpos; @@ -121,7 +121,7 @@ void DragAndDropStrategy::handleMouseMove(const QPointF& documentPos, Qt::Keyboa KUndo2Command* DragAndDropStrategy::createCommand() { const KoShape *shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); - const QPointF position = d->lastPoint - (shape ? shape->position() : QPointF(0.0, 0.0)); + const QPointF position = d->lastPoint /*- (shape ? shape->position() : QPointF(0.0, 0.0))*/; // In which cell did the user click? qreal xpos; diff --git a/tables/ui/SelectionStrategy.cpp b/tables/ui/SelectionStrategy.cpp index 8844e47..48fc486 100644 --- a/tables/ui/SelectionStrategy.cpp +++ b/tables/ui/SelectionStrategy.cpp @@ -45,7 +45,7 @@ SelectionStrategy::SelectionStrategy(CellToolBase *cellTool, d->startCell = Cell(); const KoShape* shape = tool()->canvas()->shapeManager()->selection()->firstSelectedShape(); - const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, 0.0)); + const QPointF position = documentPos /*- (shape ? shape->position() : QPointF(0.0, 0.0))*/; Sheet *const sheet = this->selection()->activeSheet(); Selection *const selection = this->selection(); Review-request for a patch that fixes it is up at https://git.reviewboard.kde.org/r/102517/ Fixed with ab38a42b294765e696bb0475ed946f3d7ef7a7f2 |