mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
+invalidate() - bugfix for crash on delete
git-svn-id: http://svn.osgeo.org/qgis/trunk@3043 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
9f3d5ba212
commit
e272db6dec
@ -394,13 +394,13 @@ void QgsComposerScalebar::sizeChanged ( )
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
void QgsComposerScalebar::move(int x, int y )
|
||||
void QgsComposerScalebar::moveBy(double x, double y )
|
||||
{
|
||||
std::cout << "QgsComposerScalebar::move" << std::endl;
|
||||
setX( (double)x );
|
||||
setY( (double)y );
|
||||
QCanvasItem::moveBy ( x, y );
|
||||
|
||||
recalculate();
|
||||
writeSettings();
|
||||
//writeSettings(); // not necessary called by composition
|
||||
}
|
||||
|
||||
void QgsComposerScalebar::recalculate ( void )
|
||||
@ -410,7 +410,12 @@ void QgsComposerScalebar::recalculate ( void )
|
||||
mHeight = (int) ( 25.4 * mComposition->scale() * mFont.pointSize() / 72);
|
||||
mMargin = (int) (3.*mHeight/2);
|
||||
|
||||
// !!! invalidate() MUST BE called before the value returned by areaPoints() changes
|
||||
QCanvasPolygonalItem::invalidate();
|
||||
|
||||
mBoundingRect = render(0);
|
||||
|
||||
QCanvasItem::update();
|
||||
}
|
||||
|
||||
QRect QgsComposerScalebar::boundingRect ( void ) const
|
||||
|
@ -125,7 +125,7 @@ public slots:
|
||||
void mapChanged ( int id );
|
||||
|
||||
// Move to position
|
||||
void move ( int x, int y );
|
||||
void moveBy ( double x, double y );
|
||||
|
||||
private:
|
||||
// Pointer to composition
|
||||
|
@ -346,14 +346,7 @@ void QgsComposition::contentsMouseMoveEvent(QMouseEvent* e)
|
||||
double x,y;
|
||||
mView->inverseWorldMatrix().map( e->pos().x(), e->pos().y(), &x, &y );
|
||||
|
||||
// TODO better move
|
||||
if ( typeid (*mSelectedItem) == typeid(QgsComposerScalebar) ) {
|
||||
QgsComposerScalebar *sb = dynamic_cast<QgsComposerScalebar *> (mSelectedItem);
|
||||
sb->move ( (int)(mSelectedItem->x() + x - mLastX), (int)(mSelectedItem->y() + y - mLastY) );
|
||||
} else {
|
||||
mSelectedItem->setX( mSelectedItem->x() + x - mLastX );
|
||||
mSelectedItem->setY( mSelectedItem->y() + y - mLastY );
|
||||
}
|
||||
mSelectedItem->moveBy ( x - mLastX, y - mLastY );
|
||||
|
||||
QgsComposerItem *ci = dynamic_cast <QgsComposerItem *> (mSelectedItem);
|
||||
ci->writeSettings();
|
||||
@ -388,14 +381,8 @@ void QgsComposition::contentsMouseMoveEvent(QMouseEvent* e)
|
||||
|
||||
case AddVectorLegend:
|
||||
case AddLabel:
|
||||
mNewCanvasItem->setX( p.x() );
|
||||
mNewCanvasItem->setY( p.y() );
|
||||
mCanvas->update();
|
||||
break;
|
||||
|
||||
case AddScalebar:
|
||||
QgsComposerScalebar *sb = dynamic_cast<QgsComposerScalebar *> (mNewCanvasItem);
|
||||
sb->move ( p.x(), p.y() );
|
||||
mNewCanvasItem->move ( p.x(), p.y() );
|
||||
mCanvas->update();
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user