Feature request #1171

Layers disappear and require restart after first time selection of anti-aliased rendering

Added by springmeyer - about 12 years ago. Updated about 11 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Map Canvas
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:11231

Description

On Mac OS X When viewing a postgis layer when first running the new metis build I changed the preferences setting to check "Make lines appear less jagged...". This immediately made the loaded layer dissapear and loading new layers and zooming to any of the layers did nothing to restore the rendered data.

A restart of the app fixed the problem and the problem does not occur when I uncheck the same setting, restart then check the settings. So their must be some subtle bug in the defaults and how the application if affected when first choosing that setting.

patch_for_1171.txt Magnifier - fix for blank map after choosing anti-alias (QImage) rendering (1.17 KB) Steven Mizuno, 2008-09-13 11:12 AM

History

#1 Updated by Steven Mizuno about 12 years ago

This problem occurs with Windows and Linux, too. The map will be drawn if the QGIS window is resized.

I also found that if using QImage, when Render is off and the QGIS window is subsequently resized, the map is drawn at the previous canvas size once Render is enabled.

Have found two problems in the code:

1. in QgsMapCanvasMap that on resize the mPixmap size is used to build mImage in render(); then the mImage is used in a paint() call, which creates mPixmap from mImage. Depending on time lag (long when Render is off) the mPixmap may be created from the mImage at the previous size or having no value (if first use). This is used the next time the map is rendered, resulting in the map being rendered at the previous size (or blank) even though the map canvas window is a different size.

2. when switching between QImage and QPixmap rendering the map canvas should be rendered.

The patch I have provided creates mImage in the resize() function of QgsMapCanvasMap rather than in render(), so it is available whenever it is needed (most of time since it is the default).

And in QgsMapCanvas::useImageToRender() refresh() is called after calling mMap->useImageToRender(). It seems better to do this at a higher so other factors control whether rendering takes place. Note that this may cause a black canvas or a previously rendered map to show if Render is off and there is a switch from QPixmap to QImage rendering.

#2 Updated by Marco Hugentobler almost 12 years ago

Is this patch still needed? I don't observe the blank map after changing the rendering type (on Linux).
Calling refresh after switch from QPixmap to QImage is a good idea.

For the moment, I'm assigning this to 1.0.1 as the patch affects a critical part of the rendering system. It seems to risky to me to apply this a few days before release.

Marco

#3 Updated by Maciej Sieczka - almost 12 years ago

Replying to [comment:2 mhugent]:

Is this patch still needed? I don't observe the blank map after changing the rendering type (on Linux).

It still takes place, but only one-way:

1. start QGIS

2. set "Fix..." in Options>Rendering

3. quit QGIS

4. start QGIS

5. load a Shapefile - it is rendered OK

6. un-set "Fix..." in Options>Rendering - mapcanvas goes blank

#4 Updated by Marco Hugentobler almost 12 years ago

Hm, it works for me also in the direction you described. Don't know what it may depend on. Perhaps the Qt version?
Anyway, I'm pushing it to 1.0.1 milestone because the patch affects a critical part of the rendering system. It seems to risky to me to apply this a few days before release.

#5 Updated by Steven Mizuno almost 12 years ago

This is a very subtle issue - the problem originally described occurs once after start up. However, resizing the map canvas causes the map size and extent to jump when switching from QPixmap to QImage. The map is drawn at the previous QImage size, then is drawn correctly on subsequent resize. I have since found that the Render toggle isn't a factor - it just may show the effects more readily.

My recollection is that the QImage has a size of 0,0 initially, which is why the map goes blank. After that the object is at its previous size and hasn't been resized when QPixmap is the rendering object. The key factors are first use or that the map canvas has been resized.

It is not Qt version related - the problem exists with either 4.3.x series or 4.4.x.

For what it's worth (I admit, I am biased) I have been applying the patch each time I obtain the latest svn copy and have not found any other problem that could be attributed to the patch. I remove the patch and test without it when I believe there may be a problem related to it.

#6 Updated by Marco Hugentobler almost 12 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

Yes, you are right, the image should be resized together with the pixmap. The patch is applied in and also in the 1.0 branch. Thanks for your great work!

Marco

#7 Updated by Anonymous about 11 years ago

Milestone Version 1.0.1 deleted

Also available in: Atom PDF