[QGIS Commit] r9066 - branches/advanced_printing_branch/src/app/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Aug 16 11:09:21 EDT 2008


Author: mhugent
Date: 2008-08-16 11:09:21 -0400 (Sat, 16 Aug 2008)
New Revision: 9066

Modified:
   branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
Log:
Don't call cache() function in composer map from paint function because of stability problems with Qt>=4.4.0

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp	2008-08-16 12:57:53 UTC (rev 9065)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp	2008-08-16 15:09:21 UTC (rev 9066)
@@ -126,6 +126,11 @@
 
 void QgsComposerMap::cache ( void )
 {
+  if(mPreviewMode == Rectangle)
+    {
+      return;
+    }
+
   int w = rect().width() * horizontalViewScaleFactor();
   int h = rect().height() * horizontalViewScaleFactor();
 
@@ -151,9 +156,6 @@
   
   draw( &p, mExtent, QSize(w, h), mCachePixmap.logicalDpiX());
   p.end();
-  
-  mNumCachedLayers = mMapCanvas->layerCount();
-  mCachedMapExtent = mExtent;
   mCacheUpdated = true;
 }
 
@@ -176,21 +178,13 @@
   painter->setClipRect (thisPaintRect);
 
   double currentScaleFactorX = horizontalViewScaleFactor();
-
-  if( mComposition->plotStyle() == QgsComposition::Preview && mPreviewMode == Render /*&& screen resolution different than last time*/)
-    {
-      if(currentScaleFactorX != mLastScaleFactorX)
-	{
-	  mCacheUpdated = false;
-	}
-    }
     
   if ( mComposition->plotStyle() == QgsComposition::Preview && mPreviewMode != Rectangle) 
-    { // Draw from cache
-      if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers || mCachedMapExtent != mExtent) 
-	{
-	  cache();
-	}
+    { 
+      //draw cached pixmap. This function does not call cache() any more because 
+      //Qt 4.4.0 and 4.4.1 have problems with recursive paintings
+      //QgsComposerMap::cache() and QgsComposerMap::update() need to be called by
+      //client functions
       
       // Scale so that the cache fills the map rectangle
       double scale = 1.0 * QGraphicsRectItem::rect().width() / mCachePixmap.width();
@@ -268,6 +262,8 @@
   mExtent.setYmin(mExtent.yMin() + yMoveMapCoord);
   mExtent.setYmax(mExtent.yMax() + yMoveMapCoord);
   emit extentChanged();
+  cache();
+  update();
 }
 
 void QgsComposerMap::setSceneRect(const QRectF& rectangle)
@@ -283,6 +279,8 @@
   mExtent = QgsRect(mExtent.xMin(), mExtent.yMin(), mExtent.xMax(), mExtent.yMin() + newHeight);
   mCacheUpdated = false;
   emit extentChanged();
+  cache();
+  update();
 }
 
 void QgsComposerMap::setNewExtent(const QgsRect& extent)
@@ -319,6 +317,7 @@
   mExtent = newExtent;
   mCacheUpdated = false;
   emit extentChanged();
+  cache();
   update();
 }
 
@@ -389,7 +388,6 @@
 
   mPreviewMode = Rectangle;
   
-#if 0 //leads to frequent crashes on Qt 4.4.0/4.4.1
   //previewMode
   QString previewMode = itemElem.attribute("previewMode");
   if(previewMode == "Cache")
@@ -404,7 +402,6 @@
     {
       mPreviewMode = Rectangle;
     }
-#endif //0
 
   //extent
   QDomNodeList extentNodeList = itemElem.elementsByTagName("Extent");
@@ -431,6 +428,12 @@
       QDomElement composerItemElem = composerItemList.at(0).toElement();
       _readXML(composerItemElem, doc);
     }
+  
+  if(mPreviewMode != Rectangle)
+    {
+      cache();
+      update();
+    }
 
   return true;
 }

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp	2008-08-16 12:57:53 UTC (rev 9065)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp	2008-08-16 15:09:21 UTC (rev 9066)
@@ -111,6 +111,7 @@
       mUpdatePreviewButton->setEnabled(false);
     }
 
+  mComposerMap->cache();
   mComposerMap->update();
 }
 
@@ -291,6 +292,7 @@
   mUpdatePreviewButton->setEnabled(false); //prevent crashes because of many button clicks
 
   mComposerMap->setCacheUpdated(false);
+  mComposerMap->cache();
   mComposerMap->update();
 
   mUpdatePreviewButton->setEnabled(true);



More information about the QGIS-commit mailing list