-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Description
Issue Description
Fixed a critical bug in the QwtSymbol.drawSymbol method that was causing a TypeError when attempting to draw a symbol into a rectangle. The error message was:
TypeError: QwtSymbol.renderSymbols() takes 3 positional arguments but 4 were given
Root Cause Analysis
This bug had two distinct causes:
-
Outdated method call: Following changeset 6a36ce7 "QwtSymbol.drawSymbols/renderSymbols: removed numPoints argument" (version 0.11), the call to
renderSymbolsin thedrawSymbolmethod was not updated to match the new signature. The method was still being called with incorrect arguments, causing the TypeError. -
Incorrect parameter type: Even after fixing the parameter count, there was another issue: the second argument of
renderSymbolsexpects a list of points (points, plural), but a singleQPointFobject was being passed directly. The method expects an iterable collection, not a single point.
Location
File: qwt/symbol.py
Method: QwtSymbol.drawSymbol
Fixed Code
The issue was fixed by:
- Updating the call to use the correct number of parameters
- Passing a list containing the single QPointF rather than the QPointF directly, as the method expects an iterable collection of points
The affected code section was in drawSymbol method:
# Before:
self.renderSymbols(painter, QPointF(), 1) # Incorrect call with wrong arguments
# After:
self.renderSymbols(painter, [QPointF()]) # Fixed call with correct argumentsImpact
This bug would prevent symbols from being properly rendered in certain contexts, particularly when using the drawSymbol method with a rectangle parameter, which is critical for displaying symbols in legends and other UI elements.
Additional Context
This bug appears to have been introduced during the transition to version 0.11 when the numPoints parameter was removed from the renderSymbols method but not all calls to this method were updated accordingly.