[Qgis-developer] ownership of QgsMessageBar(-items)

Marco Bernasocchi marco at opengis.ch
Tue May 24 02:53:52 PDT 2016


Hi Richard, I alvays wanted to make a blog post out of this:
https://github.com/mbernasocchi/pyqtExperiments/blob/master/qgis_thread_example.py

I use message bars in theads there and never had issues.

maybe it helps.

ciao
Marco

On 24.05.2016 10:48, Richard Duivenvoorde wrote:
> 
> Busy with a plugin which retrieves (in separate threads) a lot of data
> from 2 w*s services.
> 
> I thought to use the QgsMessageBar to show progress of the (two)
> download processes, but stumbled on (I think) a problem:
> 
> - from api docs: https://qgis.org/api/classQgsMessageBar.html#details
> The message bar will take ownership of the item...
> 
> My problem now is that (I think) my progressbars (which were place in a
> QgsMessageBar-item-widget) are sometimes deleted although I still want
> to use them...
> 
> For example: an user can click the little 'x' button in the messagebar
> to clean up all messages.
> Or a python dev can call 'clean all widgets'.
> 
> BUT at that moment a progressbar part of a messagebaritem is (at least
> in cpp world) apparently deleted.
> Meaning, if (in the python world) I set a progress value on it, I get a
> nice clean segmentation fault....
> 
> I managed to work around this by NOT putting the progress bars in the
> messagebar (but put small ones in the plugin toolbar), but as several
> examples flow around on Google, I thought to speak out.
> 
> Should we just not let people do this?
> 
> Or was I using the messagebar for things I was not supposed to use if for?
> 
> Or should we make an option to add a 'special' widget to the messagebar,
> which is NOT removed using clearWidgets() (either via Python or via
> x-button)?
> 
> Regards,
> 
> Richard
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

-- 
Marco Bernasocchi
OPENGIS.ch - berna.io - 27summits.ch


More information about the Qgis-developer mailing list