Skip to content

[patched-9] Port to Qt6, update for C++17/20, and improve compiler/platform support #90

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

Open
wants to merge 339 commits into
base: patched-9
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.

jbowler and others added 30 commits November 2, 2023 20:39
* replace qSort and qStableSort by 
std::stable_sort and std::sort
This completes the qSort handling in generator/ including related
changes caused by the removal of QSet<>::toList() and QSet<>::fromList()
in Qt6 (obsoleted in Qt5.14).
 - replaced it and added backwards compatibility

- provides compatibility with the removal of the global ::endl
for use with QTextStream; Qt6 requires Qt::endl
- includes Qt6 specific changes necessary to deal with the
replacement of QTextCodec by QStringConverter and the slight changes
to the default setup of QTextStream (to UTF-8 with auto-detect of
UTF-16)

---------

Signed-off-by: John Bowler <[email protected]>
The warnings are already only emitted with GCC so changing them to the
GCC diagnostic pragma is safe.
- works around the need to rewrite the XML parser in
generator/typesystem.cpp by invoking the Qt5 compatibility library;
this is the only thing in the generator which requires it but the
alternative is a complete rewrite of the XML reading code
- parses constexpr (in the manner of const) and decltype (in the manner of __typeof) 
  and adds flags for them
These changes use the new and existing support inside the parser to
handle constexpr in Qt6 files and to ignore (with a warning) 'auto'
functions.
Also add the alternate types that are available in Qt5 to replace the
types deprecated in Qt5.14 (allows Qt5.15LTS users to make changes
for compatibility with Qt6.)
- a previous fix for Qt5.12 breaks pythonqt_generator for 5.11
- includes better checking for precompiled headers and errors out early rather than
  failing when linking the src/ with mysterious missing symbols.
Expand all the tabs in non-binary source files
This is a minimal change to give the three anonymous structs used
in the generator names so that the code conforms to the existing
C++ standards.
This adds 'context' to ReportHandler warning messages; just a string
saying what is being done.
In some places the list was sorted by pointer (resulting in a random
sort) in other cases by name, sometimes with stable_sort, sometimes not.
Now sort by name and maintain do a stable_sort.
const_iterators and other iterators became visible to the generator with
changes in Qt5.14.  This removes the corresponding iterators from the
affected classes.
this way we can avoid some parser errors.
This is implemented by looking for matching braces. I hope there is no case where unmatched braces are allowed (strings and comments should be handled by the tokenizer).
…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
@jamesobutler
Copy link

@hjmjohnson I suspect all the merge conflicts here arise from @jcfr ’s own CMake implementation compared to the other developer that issued a CMake infrastructure PR. As well as @jcfr’s back porting of many commits from the upstream to the CTK patched-9 branch.

@jcfr
Copy link
Member

jcfr commented Jun 27, 2025

Thanks @hjmjohnson 🙏 , this positioned ourselves well. I will know work on consolidating the changes 🚀

@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch 5 times, most recently from bfaec20 to d384f36 Compare June 28, 2025 01:10
@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch from e9b1acf to 5c189da Compare June 28, 2025 22:38
@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch from 0e1c89b to 2c6f7fc Compare June 29, 2025 22:27
…er versions

Py_HashPointer() is not available in Python 3.12.
It was only added to the public C-API in Python 3.13 (see the “What’s New in 3.13” notes)

Release
Status of a pointer-hash helper
≤ 3.12
Only the private, internal function _Py_HashPointer() exists. It is not exported in the limited- or stable-ABI headers and may disappear or change without notice.
3.13+
Py_HashPointer(const void *ptr) becomes a public API entry in <Python.h>.
@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch from 7923b70 to a2ba4af Compare June 30, 2025 00:01
@hjmjohnson hjmjohnson force-pushed the slicer-2025-06-13-a2687828 branch from a2ba4af to d809165 Compare June 30, 2025 00:22
@jcfr jcfr changed the title Slicer 2025 06 13 a2687828 Port to Qt6, update for C++17/20, and improve compiler/platform support Jul 2, 2025
@jcfr jcfr changed the title Port to Qt6, update for C++17/20, and improve compiler/platform support [patched-9] Port to Qt6, update for C++17/20, and improve compiler/platform support Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.