Skip to content

fix: Restore case-insensitive search in File Open for PySide2 with QtCore5#174

Open
kikeda-falcons wants to merge 1 commit intoshotgunsoftware:masterfrom
kikeda-falcons:fix-case-insensitive-search-pyside2-regression
Open

fix: Restore case-insensitive search in File Open for PySide2 with QtCore5#174
kikeda-falcons wants to merge 1 commit intoshotgunsoftware:masterfrom
kikeda-falcons:fix-case-insensitive-search-pyside2-regression

Conversation

@kikeda-falcons
Copy link

Summary

Restores case-insensitive search behavior in the File Open dialog when running under PySide2 with Qt5 (e.g., Maya 2022).

This resolves Issue #173.

The fix corrects version detection and aligns regex construction with the appropriate Qt API for each major version.


Problem

Case-insensitive search stopped working in Maya environments that ship with PySide2 + Qt5. Filters behaved inconsistently depending on the Qt binding, particularly under newer Maya versions.


Root Cause

The regex creation logic attempted to infer API behavior by checking for the presence of QtCore.QRegularExpression.

This approach is unreliable because:

  • QRegularExpression exists in Qt5, but its flag handling differs from Qt6.
  • Qt6 removed QRegExp entirely and reorganized QRegularExpression flag enums.
  • The previous implementation did not properly distinguish between Qt major versions, leading to incorrect case-insensitivity handling.

As documented in Qt 5.15 (QRegularExpression API reference), Qt5 exposes QRegularExpression and its flag enums via QtCore, but its behavior and preferred usage differ from Qt6.


Solution

Use the Qt major version to determine which regex API to construct, instead of checking for attribute existence.

  • Qt5

    • Prefer QRegExp
    • Use FixedString syntax
    • Apply Qt.CaseInsensitive
    • Treat patterns as literal strings (not regex)
  • Qt6+

    • Use QRegularExpression
    • Apply CaseInsensitiveOption via setPatternOptions
    • Align with Qt6-only API surface (no QRegExp)

This makes the behavior explicit, version-correct, and stable across Maya 2022–2026.


Changes

  • Replace attribute-based detection with Qt major version check
  • Normalize regex construction logic per Qt version
  • Add inline documentation explaining Qt5 vs Qt6 differences

…ression as appropriate

Update the create_case_insensitive_regex utility to handle Qt5 and Qt6 differences more robustly. Since Qt6 removed QRegExp and reorganized QRegularExpression flag enums, the function now checks the Qt major version to select the correct API. For Qt5, it uses QRegExp with FixedString syntax for literal string matching. For Qt6+, it uses QRegularExpression with CaseInsensitiveOption set via setPatternOptions. This ensures consistent, case-insensitive, literal matching regardless of Qt version. The docstring was updated to clarify this logic.
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 32.38%. Comparing base (195a0f1) to head (c96184f).

Files with missing lines Patch % Lines
python/tk_multi_workfiles/util.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
+ Coverage   32.36%   32.38%   +0.01%     
==========================================
  Files          68       68              
  Lines        7671     7671              
==========================================
+ Hits         2483     2484       +1     
+ Misses       5188     5187       -1     
Flag Coverage Δ
Linux 32.38% <75.00%> (+0.01%) ⬆️
Python-3.10 ?
Python-3.11 32.38% <75.00%> (+<0.01%) ⬆️
Python-3.13 32.36% <75.00%> (+<0.01%) ⬆️
Python-3.9 ?
Windows 19.27% <75.00%> (+0.01%) ⬆️
macOS 32.36% <75.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant