Files
qt6-migration-pipeline/fix_qobject_includes.py
T
torstenandCopilot d6500157f1 Fix RTI detection: only call FIND_PACKAGE if manual config failed
- Wrap FIND_PACKAGE(RTI) in IF(NOT TARGET RTI::nddsc) condition
- Prevents placeholder targets from overwriting manually configured RTI:: targets
- Manual configuration creates RTI:: targets when BUILD_RTI=ON and RTI found
- FIND_PACKAGE only called as fallback when manual config doesn't create targets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: 01M1CT3XSQXCX9RQR6WM9DG3GH
2026-08-31 23:03:01 +02:00

74 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""
Fix QObject includes - must stay in QtCore, not QtGui!
QObject is a Core class, not a Gui class.
"""
import os
import re
def fix_qobject_includes(filepath):
"""Fix QObject includes - change QtGui/QObject back to QtCore/QObject"""
try:
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
except Exception as e:
return 0
original = content
fixed_count = 0
# Fix QtGui/QObject -> QtCore/QObject
pattern = r'#include\s*<QtGui/QObject>'
replacement = '#include <QtCore/QObject>'
matches = re.findall(pattern, content)
if matches:
content = re.sub(pattern, replacement, content)
fixed_count = len(matches)
if fixed_count > 0 and content != original:
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
return fixed_count
def main():
total_fixed = 0
files_fixed = 0
files_scanned = 0
# Search in Lts/ and include/ directories
search_dirs = ['qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts',
'qt-migration-legatus/qt6-after/qt6-migrated-legatus/include']
for search_dir in search_dirs:
if not os.path.exists(search_dir):
continue
for root, dirs, files in os.walk(search_dir):
# Skip build directories
dirs[:] = [d for d in dirs if d not in ['build', '.git']]
for file in files:
if not (file.endswith('.h') or file.endswith('.cpp') or
file.endswith('.hpp') or file.endswith('.cc') or
file.endswith('.cxx')):
continue
filepath = os.path.join(root, file)
files_scanned += 1
fixed = fix_qobject_includes(filepath)
if fixed > 0:
total_fixed += fixed
files_fixed += 1
print(f"Fixed {fixed} QObject includes in {filepath}")
print(f"\n=== QObject Include Fix Summary ===")
print(f"Files scanned: {files_scanned}")
print(f"Files fixed: {files_fixed}")
print(f"Total fixes: {total_fixed}")
if __name__ == '__main__':
main()