[Qgis-developer] Re: [QGIS Commit] [g_j_m] r5068 - trunk/qgis/src/gui

Gavin Macaulay gavin at macaulay.co.nz
Mon Mar 20 15:50:54 EST 2006


Brendan,

I'm not sure that I understand your suggestion. What are the two Qt 
buffers for? I can see the need for one, but what is the second for?

The problem seems (to me) to be that QPainter won't allow nested 
painting, and this is occurring because of how the Qgis code is 
structured - there is a QPainter that lives for as long as it takes to 
draw all of the map layers, and the progress bar is being updated while 
that QPainter is around, and presumably the progress bar is trying to 
paint to the same QImage or QPixmap as the one used by the Qgis map 
QPainter. Does that seem correct?

A solution could be to separate the painting of the map into small 
blocks and use a new QPainter for each block, interspersing them with 
calls to update the progress bar - essentially removing the nesting.

Gavin

Brendan Morley wrote:
> Gavin,
> 
> An idea I had for getting around the nested paint event is this:
> 
> Somehow we "triple-buffer" the canvas, where Qt provides the first 2
> buffers and canvas operations write to the third.
> 
> Then a paint event is "simply" a matter of copying the third buffer to
> the first pair. - a quick event.  Before and after, the canvas can
> continue to be composed.
> 
> Thoughts?
> 
> 
> Brendan
> 
> On Mon, 2006-03-20 at 02:42 +0000, noreply at qgis.org wrote:
>> Author: g_j_m
>> Date: 2006-03-20 02:42:21 +0000 (Mon, 20 Mar 2006)
>> New Revision: 5068
>>
>> Modified:
>>    trunk/qgis/src/gui/qgsmaprender.cpp
>> Log:
>> Add a little debug output to make clear the source of the QPaintEngine
>> error
>>
>>
>> Modified: trunk/qgis/src/gui/qgsmaprender.cpp
>> ===================================================================
>> --- trunk/qgis/src/gui/qgsmaprender.cpp	2006-03-19 17:58:13 UTC (rev 5067)
>> +++ trunk/qgis/src/gui/qgsmaprender.cpp	2006-03-20 02:42:21 UTC (rev 5068)
>> @@ -205,6 +205,15 @@
>>      std::cout << "QgsMapRender::render: at layer item '" << (*li).toLocal8Bit().data() << "'." << std::endl;
>>  #endif
>>  
>> +    // This call is supposed to cause the progress bar to
>> +    // advance. However, it seems that updating the progress bar is
>> +    // incompatible with having a QPainter active (the one that is
>> +    // passed into this function), as Qt produces a number of errors
>> +    // when try to do so. I'm (Gavin) not sure how to fix this, but
>> +    // added these comments and debug statement to help others...
>> +    std::cerr << "If there is a QPaintEngine here, it is caused by an emit "
>> +      "call just after line " << __LINE__ << " in file " << __FILE__ << ".\n";
>> +
>>      emit setProgress(myRenderCounter++,layers.size());
>>      QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(*li);
>>  



More information about the Qgis-developer mailing list