+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:
rabla 2005-03-30 08:55:11 +00:00
parent 9f3d5ba212
commit e272db6dec
3 changed files with 12 additions and 20 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}