Skip to content

WIP: NOT READY FOR REVIEW Slicer 2025 06 13 a2687828 #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

hjmjohnson
Copy link

A summary of all changes from mevislab/master to the current HEAD (slicer-2025-06-13-a2687828):

Qt6 Porting: Updated code to support Qt6, including replacing deprecated QVariant::Type with QMetaType and adding version checks for Qt5/Qt6 compatibility.
C++17/20 Modernization: Refactored code to use modern C++ features as required by newer Qt versions (e.g., constexpr, noexcept, alignas, etc.).
Compiler Detection Updates: Enhanced and updated compiler detection macros in qcompilerdetection.h for better support of recent compilers and platforms.
Warning and Attribute Macros: Improved handling of compiler warnings and attributes, including support for new C++ attributes like [[nodiscard]], [[maybe_unused]], and [[deprecated]].
Platform and Feature Checks: Added or updated macros for platform-specific and feature-specific checks, ensuring better cross-platform compatibility.
General Maintenance: Bug fixes, code cleanup, and improved documentation/comments throughout the codebase.
These changes collectively modernize the codebase, improve compatibility with recent Qt and C++ standards, and enhance maintainability.

feihong and others added 30 commits June 27, 2025 06:56
add static link support
add CMake build support to PythonQtGenerator
prefer to use ${CMAKE_CURRENT_LIST_DIR}/generated_cpp
add custom targets to automatically run generated commands
Initial support for using auto-generated wrappers
enable testing
add cmake ci
CMake CI Process Validation
Update cmake.yml
adapting more Qt header file include paths
fix _qt_include_prefix

Captured partial cmake rewrite from
```
REMOTE: [email protected]:feihong-gz/pythonqt.git
commit d02ca888ffca2012307bfe9d5e1a176eb95f0cfc
Author: feihong <[email protected]>
Date:   2025-02-13 02:08:42 -0500
```
Add initial documentation for how to install
Qt6 on Ubuntu 24.04.

Update README with improved build instructions, CMake usage,
platform-specific notes, and developer hints
warning: Don't create temporary QRegularExpression objects. Use a
static QRegularExpression object instead [-Wclazy-use-static-qregularexpression]

Is alerting that the same QRegularExpression object is re-created
every time a function is called or expression is evaluated. This is
inefficient, especially for repeated use, because QRegularExpression has
a non-trivial construction cost (it compiles the regex pattern).

auto match = re.match(content);
PythonQt/generator/main.cpp:98:60: warning: adding 'bool' to a string does not append to the string [-Wstring-plus-int]
        QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
PythonQt/generator/main.cpp:98:60: note: use array indexing to silence this warning
        QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
                                                           ^
                         &                                 [                ]
PythonQt/generator/main.cpp:98:78: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
        QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
PythonQt/generator/main.cpp:98:78: note: place parentheses around the '+' expression to silence this warning
        QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
                                                                             ^
                         (                                                  )
PythonQt/generator/main.cpp:98:78: note: place parentheses around the '?:' expression to evaluate it first
        QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
PythonQt/generator/parser/name_compiler.cpp:111:46: \
    warning: 'count' is deprecated: Use size() or length() instead.
    [-Wdeprecated-declarations]
Add preprocessor conditional to use PyUnicode_FromString for Qt6 and PyString_FromString for earlier versions, ensuring compatibility with both Qt5 and Qt6.
The use of Q_FOREACH is deprecated.

Replaced instances of `foreach` with range-based `for`
loops for modernization and code consistency.
Prefer to build in Release mode if not set.
Only search for one of Qt5 or Qt6

Never search for both Qt5 and Qt6 simultaneously.
Requiring user to specify the source bindings to
create.
Replace with backward compatible recommended or
preprocessor conditional for old and new.

Use new paradigms that are backward compatible
when possible.

Use preprocessor conditionals where the syntax
is different between qt5 and qt6.
Add specific framework path handling

Refactor include directory parsing to support multiple candidate paths
for headers and introduce macOS-specific logic for resolving
framework-relative header paths. Enhance generator flexibility and
robustness for cross-platform usage.

Push upstream fix via:
danmar/simplecpp#448
`#ifndef PY3K` conditionals and related logic

Removal of PY3k ifdef ifndef not done correctly.
Simplified the code by removing legacy preprocessor conditionals for Python versions < 2.4. Used the consistent `PyMarshal_Write*` API with `Py_MARSHAL_VERSION`.
Ensure that the CMake codegen and test environments have the environmental variables set as described in the
Readme.md file.
…/6 compatibility

Explicitly exclude `qtscript_masterinclude.h` from sources. Add compatibility for Qt5 and Qt6 with conditional linking of `Core5Compat` library.
Enhanced logic to handle potential subdirectories like "QtCore" and added fallback for frameworks without "QtCore" suffixed, improving compatibility with various Qt installations.
Improve error handling by introducing validation to ensure input files exist and are readable before proceeding, enhancing robustness of the generator.
…ndling

Introduce `build_all_qt6.txt` for Qt6 builds and update generator to conditionally copy appropriate resource files. Improved resource copying logic and adjusted CMake commands for enhanced Qt5/6 compatibility.
…requirements

Removed repetitive Qt version conditionals across multiple CMake files. Consolidated and streamlined required Qt components for both Qt5 and Qt6, ensuring consistency and reducing redundancy.
… in generator

Introduce `dirExistsAndReadable` utility to validate include directories before use and enhance debugging output for include resolution in the generator.
Introduce compile-time options to prevent dangerous implicit casting in Qt. Add `PythonQt_NO_IMPLICIT_CASTING` for optional stricter casting rules.
…ce files

Replaced `file(GLOB)` usage with explicit lists for source and public header files. Improved clarity and maintainability of project structure in CMake configuration.
Update generator environment handling

Refactor CMake to improve Qt6 include path detection with duplicate
removal. Add logic for dynamically collecting Qt components and include
directories. Update generator commands to include accessible Qt paths
for more robust environment configuration.
…ffix

Refine `PYTHONQT_GENERATED_PATH` to append Qt major and minor version, improving compatibility and build separation for different Qt versions.
Enhance include directory parsing to handle macOS-specific framework paths, stripping `.framework/Headers` or `.framework` suffixes when appropriate. Ensure accurate and duplicate-free Qt6 include path collection.
…-specific suffix

Remove the addition of the Qt version-specific suffix to `PYTHONQT_GENERATED_PATH` as it caused conflicts due to the hardcoded logic in `setupgenerator.cpp`. Add a note for clarification.
qprintengine.h:12:1: error: explicit specialization of
   'QMetaTypeId<QMarginsF>' after instantiation
…lity

Update all references from `QVariant::Type` to `QMetaType::Type`
across the generated files for improved alignment with Qt's data
type handling.
Add conditional checks for the `verbose` flag to distinguish
between legacy `Py_VerboseFlag` `Py_OptimizeFlag` and modern `sys.verbose` usage,
ensuring compatibility with Python versions 3.11 and later.

• Python is moving away from global interpreter state.
• Use of global variables like Py_VerboseFlag is not thread-safe.
• Python 3.12+ removes or restricts access to such globals in favor of
  per-interpreter APIs.
@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch from 1240594 to 48dd28f Compare June 27, 2025 11:16
@mrbean-bremen
Copy link
Contributor

The description seems to be related to the merge from mevislab to slicer, not vice verse... got me confused at first.

@hjmjohnson hjmjohnson changed the title Slicer 2025 06 13 a2687828 WIP: NOT READY FOR REVIEW Slicer 2025 06 13 a2687828 Jun 30, 2025
@hjmjohnson hjmjohnson marked this pull request as draft June 30, 2025 19:02
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