Skip to content

TypeError in QwtSymbol.drawSymbol method due to outdated renderSymbols call #100

@PierreRaybaut

Description

@PierreRaybaut

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:

  1. Outdated method call: Following changeset 6a36ce7 "QwtSymbol.drawSymbols/renderSymbols: removed numPoints argument" (version 0.11), the call to renderSymbols in the drawSymbol method was not updated to match the new signature. The method was still being called with incorrect arguments, causing the TypeError.

  2. Incorrect parameter type: Even after fixing the parameter count, there was another issue: the second argument of renderSymbols expects a list of points (points, plural), but a single QPointF object 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:

  1. Updating the call to use the correct number of parameters
  2. 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 arguments

Impact

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions