#!/usr/bin/env python3 """ Fix flt_dtc.h includes - replace with forward declaration where possible """ import os import re base_dir = "qt-migration-legatus/qt6-after/qt6-migrated-legatus" files_to_fix = [ "Lts/Plugins/FilterManagement/flt_symbol_appearance_settings.h", "Lts/Plugins/FilterManagement/flt_data_plugin_interface.h", "Lts/Plugins/FilterManagement/flt_data_plugin_aes_display_filter.h", "Lts/Plugins/FilterManagement/flt_building_cmpnt_settings.h", "Lts/Plugins/SituationMapPlugin/Gui/SituationMap/AdapterDds/hitlineinfo_to_map.h", "Lts/Plugins/SituationMapPlugin/Gui/SituationMap/AdapterDds/buildinghitlineinfo_to_map.h", ] for rel_path in files_to_fix: full_path = os.path.join(base_dir, rel_path) if not os.path.exists(full_path): print(f"SKIP (not found): {rel_path}") continue with open(full_path, 'r') as f: content = f.read() # Check if SymbolAppearance is used as reference/pointer (forward decl ok) # or if full type definition is needed # Remove the include old_include = '#include ' if old_include not in content: print(f"SKIP (no include): {rel_path}") continue # Add forward declaration after namespace FilterManagement { forward_decl = "class SymbolAppearance;" # Find namespace FilterManagement ns_pattern = r'(namespace\s+FilterManagement\s*\{)' def replace_func(match): ns_decl = match.group(1) # Check if forward decl already exists after_ns = content[match.end():match.end()+200] if 'class SymbolAppearance;' in after_ns or 'struct SymbolAppearance;' in after_ns: return ns_decl # Already has forward decl return ns_decl + '\n' + forward_decl new_content = re.sub(ns_pattern, replace_func, content) new_content = new_content.replace(old_include + '\n', '') new_content = new_content.replace(old_include, '') with open(full_path, 'w') as f: f.write(new_content) print(f"FIX: {rel_path}") print("\nDone!")