Hi all, On 11/4/25 09:22, Julien Cabieces via QGIS-Developer wrote:
Why not plain old callbacks instead of signals (I don't like that much signals, It's hard to debug, I think we use them too much). QgsSymbol could have some methods like thisvoid addModifiedCallback( std::function<void> callback ) { mCallbacks.append( callback ); } void dirty() { for( auto callback : mCallbacks ) callback(); } void setSize( double size ) { ... dirty(); } And QgsFeatureRenderer would report it to QgsVectorLayer, which would then report it to QgsProject
I don't have an opinion on dirtying (due to lack of experience with it), but I do have an opinion on signals and callbacks:
I agree that QGIS sometimes overuses signals, but I think callbacks are only a reasonable replacement where there will be exactly one callback, and only when that callback isn't stored in an object.
Apart from the code duplication introduced by manually handling lists of callback functions (and slowly reimplementing signals ourselves), signals, when attached to objects, will automatically respond to the destruction of one of the endpoints. This means that properly-connected signals will never cause use-after-free issues, and that is reason enough to use them, in my opinion.
David Koňařík _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
