Skip to content

qtvcp: fix PyQt5 ≥ 5.15 and PyQt6 compatibility#3943

Open
bgermann wants to merge 2 commits intoLinuxCNC:masterfrom
bgermann:qtpy
Open

qtvcp: fix PyQt5 ≥ 5.15 and PyQt6 compatibility#3943
bgermann wants to merge 2 commits intoLinuxCNC:masterfrom
bgermann:qtpy

Conversation

@bgermann
Copy link
Copy Markdown
Contributor

This is a follow-up on #3881

Replace removed Qt APIs and fix strict enum type checking:

- Replace QRegExp/QRegExpValidator with QRegularExpression/
  QRegularExpressionValidator

- Fix QDialogButtonBox.addButton() calls passing bare int 3
  instead of QDialogButtonBox.ActionRole

- Fix setSortIndicator() passing bare int instead of Qt.SortOrder
  enum

- Fix QLinearGradient() rejecting QPoint arguments (requires
  QPointF)

- Fix QVariant usage in table models: replace QVariant() returns
  with None, QVariant(x) returns with x, and QVariant.Double/Int
  type ID constants with a try/except fallback to Qt metatype
  integers

- Add try/except fallback for QEnum import (qtpy ≥ 2.0.0) with
  fallback to Q_ENUM and Q_ENUMS for older versions
GCodeGraphics._hal_cleanup() never stopped the QTimer or the
positionlogger background thread before HAL.exit() freed LinuxCNC's
shared memory. The C logger loop continued accessing NML/status memory
that had already been deallocated, causing a use-after-free segfault.

Stop the Qt poll timer and call logger.stop() at the start of
_hal_cleanup(), mirroring the shutdown sequence used by AXIS.
@c-morley
Copy link
Copy Markdown
Collaborator

I suggest adding:

    LOG.info('green<Qt version: {}>'.format(QtCore.qVersion()))

on about line 171 in qtvcp.py, so we know what bindings are being used.

you can force pyqt6 by adding:

os.environ['QT_API'] = 'pyqt6'

on about line 11 in qtvcp.py

@c-morley
Copy link
Copy Markdown
Collaborator

In indicatorMixin.py I get erros related to using toPointF() need to switch to QPointF instead eg:

gradient = QtGui.QLinearGradient((top_bot + QtCore.QPointF(size, 0)), top_bot)

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.

2 participants