Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#1171 closed patch (fixed)

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

Reported by: springmeyer Owned by: nobody
Priority: major: does not work as expected Milestone:
Component: MapCanvas Version: Trunk
Keywords: Cc:
Must Fix for Release: Yes Platform: All
Platform Version: Awaiting user input: no

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.

Attachments (1)

patch_for_1171.txt (1.2 KB ) - added by smizuno 16 years ago.
fix for blank map after choosing anti-alias (QImage) rendering

Download all attachments as: .zip

Change History (8)

comment:1 by smizuno, 16 years ago

Platform: OS XAll
Type: bugpatch

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.
  1. 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.

by smizuno, 16 years ago

Attachment: patch_for_1171.txt added

fix for blank map after choosing anti-alias (QImage) rendering

comment:2 by mhugent, 15 years ago

Milestone: Version 1.0.0Version 1.0.1

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

in reply to:  2 comment:3 by msieczka, 15 years ago

Milestone: Version 1.0.1Version 1.0.0
Must Fix for Release: NoYes
Priority: minor: annoyance or enhancementmajor: does not work as expected
Version: 0.11.0HEAD

Replying to 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
  1. set "Fix..." in Options>Rendering
  1. quit QGIS
  1. start QGIS
  1. load a Shapefile - it is rendered OK
  1. un-set "Fix..." in Options>Rendering - mapcanvas goes blank

comment:4 by mhugent, 15 years ago

Milestone: Version 1.0.0Version 1.0.1

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.

comment:5 by smizuno, 15 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.

comment:6 by mhugent, 15 years ago

Resolution: fixed
Status: newclosed

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

Marco

comment:7 by (none), 15 years ago

Milestone: Version 1.0.1

Milestone Version 1.0.1 deleted

Note: See TracTickets for help on using tickets.