Skip to content

Commit 5a27e1b

Browse files
author
mhugent
committed
Better protection agains multiple map drawings with move content tool
git-svn-id: http://svn.osgeo.org/qgis/trunk@9174 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8520ec5 commit 5a27e1b

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/app/composer/qgscomposer.h

-7
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
212212
/**Etablishes the signal slot connection for the class*/
213213
void connectSlots();
214214

215-
/** \brief move up the content of the file
216-
\param file file
217-
\param from starting position
218-
\param shift shift in bytes
219-
*/
220-
bool shiftFileContent( QFile *file, qint64 start, int shift );
221-
222215
//! Set buttons up
223216
void setToolActionsOff( void );
224217

src/app/composer/qgscomposermapwidget.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ void QgsComposerMapWidget::on_mPreviewModeComboBox_activated( int i )
9898
return;
9999
}
100100

101+
if(mComposerMap->isDrawing())
102+
{
103+
return;
104+
}
105+
101106
QString comboText = mPreviewModeComboBox->currentText();
102107
if ( comboText == tr( "Cache" ) )
103108
{

src/core/composer/qgscomposermap.cpp

+26-22
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
100100
return;
101101
}
102102

103+
if ( mDrawing )
104+
{
105+
return;
106+
}
107+
108+
mDrawing = true;
109+
103110
QgsMapRenderer theMapRenderer;
104111
theMapRenderer.setExtent( extent );
105112
theMapRenderer.setOutputSize( size, dpi );
@@ -119,6 +126,8 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRect& extent, const QSize
119126
theMapRenderer.setScale( scale() );
120127
theMapRenderer.render( painter );
121128
theMapRenderer.setScale( bk_scale );
129+
130+
mDrawing = false;
122131
}
123132

124133
void QgsComposerMap::cache( void )
@@ -158,18 +167,11 @@ void QgsComposerMap::cache( void )
158167

159168
void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
160169
{
161-
if ( mDrawing )
162-
{
163-
return;
164-
}
165-
166170
if ( !mComposition || !painter )
167171
{
168172
return;
169173
}
170174

171-
mDrawing = true;
172-
173175
QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
174176
painter->save();
175177
painter->setClipRect( thisPaintRect );
@@ -218,7 +220,6 @@ void QgsComposerMap::paint( QPainter* painter, const QStyleOptionGraphicsItem* i
218220
painter->restore();
219221

220222
mLastScaleFactorX = currentScaleFactorX;
221-
mDrawing = false;
222223
}
223224

224225
void QgsComposerMap::mapCanvasChanged( void )
@@ -251,20 +252,23 @@ void QgsComposerMap::resize( double dx, double dy )
251252

252253
void QgsComposerMap::moveContent( double dx, double dy )
253254
{
254-
QRectF itemRect = rect();
255-
double xRatio = dx / itemRect.width();
256-
double yRatio = dy / itemRect.height();
257-
258-
double xMoveMapCoord = mExtent.width() * xRatio;
259-
double yMoveMapCoord = -( mExtent.height() * yRatio );
260-
261-
mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
262-
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
263-
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
264-
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
265-
emit extentChanged();
266-
cache();
267-
update();
255+
if(!mDrawing)
256+
{
257+
QRectF itemRect = rect();
258+
double xRatio = dx / itemRect.width();
259+
double yRatio = dy / itemRect.height();
260+
261+
double xMoveMapCoord = mExtent.width() * xRatio;
262+
double yMoveMapCoord = -( mExtent.height() * yRatio );
263+
264+
mExtent.setXMinimum( mExtent.xMin() + xMoveMapCoord );
265+
mExtent.setXMaximum( mExtent.xMax() + xMoveMapCoord );
266+
mExtent.setYmin( mExtent.yMin() + yMoveMapCoord );
267+
mExtent.setYmax( mExtent.yMax() + yMoveMapCoord );
268+
emit extentChanged();
269+
cache();
270+
update();
271+
}
268272
}
269273

270274
void QgsComposerMap::setSceneRect( const QRectF& rectangle )

src/gui/qgscomposerview.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
189189
double moveX = scenePoint.x() - mMoveContentStartPos.x();
190190
double moveY = scenePoint.y() - mMoveContentStartPos.y();
191191
mMoveContentItem->moveContent( -moveX, -moveY );
192-
mMoveContentItem->update();
193192
mMoveContentItem = 0;
194193
}
195194
break;

0 commit comments

Comments
 (0)