Skip to content

Simplify field specializations#849

Closed
magnesj wants to merge 21 commits intodevfrom
pdm-compile-bench
Closed

Simplify field specializations#849
magnesj wants to merge 21 commits intodevfrom
pdm-compile-bench

Conversation

@magnesj
Copy link
Copy Markdown
Owner

@magnesj magnesj commented Apr 4, 2026

No description provided.

magnesj and others added 19 commits April 2, 2026 21:28
…nt/pdmVariantEqual

Introduces free function customization points to replace PdmValueFieldSpecialization.
Default implementations handle Qt-metatype-registered types. Overloads provided for
std::vector, std::pair, PdmPointer, AppEnum, FilePath, float, and double.
…riant free functions

Replace PdmValueFieldSpecialization class templates in Vec3d, Mat4d, Color3f, Mat3d headers
with free function overloads pdmToVariant/pdmFromVariant and full specializations of
pdmVariantEqual. Update all call sites in unit tests and application code accordingly.
…free functions

Replace PdmValueFieldSpecialization<T>::convert/setFromVariant calls with
pdmToVariant/pdmFromVariant free functions in PdmDataValueField, PdmProxyValueField,
PdmUiCheckBoxAndTextEditor, and PdmUiValueRangeEditor.
…tEqual free functions

Replace all PdmValueFieldSpecialization<T>::convert, setFromVariant, and isEqual calls
in PdmUiFieldSpecializationForValueSpec, std::vector/pair/optional specializations, and
PdmFieldUiCap::isQVariantDataEqual.
…ining call sites

Delete the old policy class header. Update unit tests, comment references, and CMakeLists.
All consumers now use pdmToVariant/pdmFromVariant/pdmVariantEqual from cafPdmFieldTraits.h.
- PdmUiFieldSpecialization<PdmPointer<T>> and <AppEnum<T>> now delegate convert/setFromVariant
  to pdmToVariant/pdmFromVariant instead of duplicating the same logic
- Add list.reserve() in pdmToVariant(std::vector<T>) to avoid repeated reallocations
…n build

- Add cafPdmFieldTraitsTest.cpp with 33 tests covering round-trips and
  pdmVariantEqual for int, double, float, bool, QString, FilePath,
  AppEnum, vector, pair, and PdmPointer types
- Add VariantEqualTest to cafPdmCoreVec3dTest.cpp and cafPdmCoreColor3fTest.cpp
- Include cafPdmCvf_UnitTests in RESINSIGHT_INCLUDE_APPFWK_TESTS build
Add std::optional overloads to cafPdmFieldTraits.h so optional fields
round-trip correctly and pdmVariantEqual<std::optional<T>> uses the
has-value/empty-QVariant convention rather than falling back to
a.value<std::optional<T>>() which always returns nullopt.

Simplify PdmUiFieldSpecialization<std::optional<T>> to delegate to the
free functions. Add 7 tests covering round-trip and equality.
Move type-specific free function overloads into the headers that define
those types (cafPdmPointer.h, cafAppEnum.h, cafFilePath.h), so a simple
PdmField<int> no longer forces every TU to parse those heavy headers.

Replace if constexpr dispatch in pdmVariantEqual with PdmVariantEqualImpl<T>
class template partial specializations, which also fixes the extensibility
for nested containers (e.g. std::vector<cvf::Vec3d>) since class template
partial specialization is allowed where function template partial
specialization is not.

cafPdmFieldTraits.h now only requires <QVariant> and standard library
headers. Each type's equality and conversion logic lives next to its type.
- Remove redundant forward declarations for PdmPointer/AppEnum in
  cafInternalPdmFieldTypeSpecializations.h (full headers now included)
- Fix std::list<T> specialization to use pdmToVariant/pdmFromVariant
  instead of raw QVariant(*it)/lst[i].value<T>() — consistent with vector
- Remove redundant #include <QVariant> from cafAppEnum.h and cafFilePath.h
  (already provided by cafPdmFieldTraits.h)
- Simplify PdmVariantEqualImpl<optional<T>>::equal to use !a.isValid()
  instead of allocating toString().remove('"').isEmpty() — pdmToVariant
  for nullopt always produces QVariant() (invalid)
…ter and std::optional

PdmUiFieldSpecialization<PdmPointer<T>> and PdmUiFieldSpecialization<std::optional<T>>
were pure pass-throughs to pdmToVariant/pdmFromVariant/pdmVariantEqual, identical in
behavior to the primary template. Removing them lets the primary template handle these
types via ADL. Also removes the cafPdmObjectHandle.h include which was only needed for
the PdmPointer specialization, reducing include weight for all TUs using cafPdmUiFieldSpecialization.h.
Adds cafPdm_CompileBench, an OBJECT library with five translation units
that each define 20 PdmObject subclasses using different field types:
basic (int/double/bool/QString), AppEnum, containers (vector/optional/pair),
FilePath, and a mixed file covering all types.

Unity build is explicitly disabled on the target so each file compiles
independently, giving per-file timing via ninja -j1.
Move <QIcon> and <QPixmap> out of cafIconProvider.h into cafIconProvider.cpp
by declaring the destructor out-of-line. This prevents these heavy Qt GUI
headers from being pulled into every translation unit that includes
cafPdmObject.h.

Remove cafPdmOptionItemInfo.h from cafPdmUiItem.h — PdmUiItem does not use
PdmOptionItemInfo directly. Move the include to cafPdmUiFieldHandle.h and
cafPdmUiObjectHandle.h which actually require it. Fix downstream headers
that relied on the transitive include (cafPdmUiItemInfo.h, cafPdmUiFieldEditorHandle.h).

Measured improvement over dev branch: 3–7% reduction in bench file compile
times, stacking on top of the cafPdmFieldTraits.h include-weight reduction.
Restore cafPdmOptionItemInfo.h in cafPdmUiItem.h — the prior commit
removed it too aggressively, breaking ~70 downstream headers that relied
on the transitive include. Re-adding it is still cheaper than before
because cafIconProvider.h no longer pulls in <QIcon>/<QPixmap>.

Add direct includes to files that used CAF_ASSERT, PdmObjectHandle,
PdmFieldHandle, PdmUiFieldHandle, QIcon, QRect, or PdmOptionItemInfo
through the now-broken transitive chain:

- cafPdmUiCore: cafPdmUiItemInfo.cpp, cafPdmOptionItemInfo.cpp,
  cafPdmUiItem.cpp — add <QIcon>
- cafPdmUiCore: cafPdmUiEditorHandle.cpp — add cafAssert.h
- cafPdmUiCore: cafPdmUiFieldHandle.cpp — add cafPdmObjectHandle.h
- cafPdmUiCore: cafFontTools.cpp — add cafPdmOptionItemInfo.h
- cafPdmUiCore: cafPdmUiFieldEditorHandle.h — forward-declare PdmFieldHandle
- cafPdmUiCore: cafPdmUi3dObjectEditorHandle.h — forward-declare PdmUiFieldHandle
- cafUserInterface: cafPdmUiLineEditor.h — add cafPdmOptionItemInfo.h
- cafUserInterface: cafPdmUiFormLayoutObjectEditor.h — forward-declare
  PdmFieldHandle and PdmUiFieldHandle
- cafUserInterface: cafPdmUiTableViewEditor.h — forward-declare PdmObjectHandle
- cafUserInterface: cafPdmUiTreeAttributes.h — add <QRect>, forward-declare
  PdmObjectHandle
- cafUserInterface: cafPdmUiTreeSelectionQModel.h — add cafPdmOptionItemInfo.h,
  remove now-redundant forward declaration
- cafTestApplication: CustomObjectEditor.cpp — add cafAssert.h (pre-existing bug)
- ApplicationLibCode: RiaOptionItemFactory.h, RiaQDateTimeTools.cpp,
  RimDataSourceSteppingTools.h — add cafPdmOptionItemInfo.h
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Replace PdmValueFieldSpecialization with ADL-based pdmToVariant/pdmFromVariant free functions

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Replace PdmValueFieldSpecialization class templates with ADL-based free functions
  - Introduces pdmToVariant, pdmFromVariant, pdmVariantEqual customization points
  - Simplifies type specialization and improves code maintainability
• Migrate all call sites to new free function API
  - Updates PDM field classes, UI editors, and application code
  - Removes old cafInternalPdmValueFieldSpecializations.h header
• Add comprehensive test coverage for field traits
  - New cafPdmFieldTraitsTest.cpp with 40+ test cases
  - Tests round-trip conversions and equality comparisons
• Add compile-time benchmarks for PDM field types
  - Five benchmark files measuring instantiation cost
  - Helps track performance impact of field specializations
Diagram
flowchart LR
  A["PdmValueFieldSpecialization<br/>class templates"] -->|"Replaced by"| B["pdmToVariant<br/>pdmFromVariant<br/>pdmVariantEqual<br/>free functions"]
  B -->|"Enables"| C["Type specializations<br/>via overloads"]
  C -->|"Supports"| D["Basic types<br/>Containers<br/>Custom types"]
  E["cafPdmFieldTraits.h<br/>new header"] -->|"Provides"| B
  F["Removed<br/>cafInternalPdmValueFieldSpecializations.h"] -->|"Replaced by"| E
Loading

Grey Divider

File Changes

1. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldTraits.h ✨ Enhancement +212/-0

New ADL-based customization point header

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldTraits.h


2. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h Miscellaneous +0/-239

Removed old policy class specializations

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h


3. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h ✨ Enhancement +5/-3

Migrate to pdmToVariant/pdmFromVariant free functions

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h


View more (57)
4. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmProxyValueField.h ✨ Enhancement +5/-3

Migrate to pdmToVariant/pdmFromVariant free functions

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmProxyValueField.h


5. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPointer.h ✨ Enhancement +30/-0

Add free function overloads for PdmPointer

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmPointer.h


6. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h ✨ Enhancement +25/-0

Add free function overloads for AppEnum

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAppEnum.h


7. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h ✨ Enhancement +23/-0

Add free function overloads for FilePath

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h


8. Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h ✨ Enhancement +18/-27

Replace class template with free functions

Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h


9. Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h ✨ Enhancement +18/-27

Replace class template with free functions

Fwk/AppFwk/cafPdmCvf/cafPdmCoreMat4d.h


10. Fwk/AppFwk/cafPdmCvf/cafPdmCoreColor3f.h ✨ Enhancement +15/-24

Replace class template with free functions

Fwk/AppFwk/cafPdmCvf/cafPdmCoreColor3f.h


11. Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmCoreMat3d.h ✨ Enhancement +20/-27

Replace class template with free functions

Fwk/AppFwk/cafPdmCvf/cafPdmMat3d/cafPdmCoreMat3d.h


12. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h ✨ Enhancement +35/-100

Update UI field specializations to use free functions

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h


13. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl ✨ Enhancement +1/-1

Replace isEqual call with pdmVariantEqual

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmUiFieldCapability.inl


14. Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp ✨ Enhancement +2/-2

Migrate to pdmToVariant free function

Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxAndTextEditor.cpp


15. Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp ✨ Enhancement +2/-2

Migrate to pdmToVariant free function

Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp


16. ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp ✨ Enhancement +3/-3

Migrate to pdmFromVariant free function

ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp


17. ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp ✨ Enhancement +3/-3

Migrate to pdmToVariant free function

ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp


18. ApplicationLibCode/Commands/AnnotationCommands/RicTextAnnotation3dEditor.cpp ✨ Enhancement +1/-1

Migrate to pdmToVariant free function

ApplicationLibCode/Commands/AnnotationCommands/RicTextAnnotation3dEditor.cpp


19. ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp ✨ Enhancement +1/-1

Migrate to pdmToVariant free function

ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPolylineTarget3dEditor.cpp


20. ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp ✨ Enhancement +1/-1

Migrate to pdmFromVariant free function

ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGeometryDef.cpp


21. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmFieldTraitsTest.cpp 🧪 Tests +490/-0

New comprehensive test suite for field traits

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmFieldTraitsTest.cpp


22. Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreVec3dTest.cpp 🧪 Tests +16/-2

Add variant equality tests for Vec3d

Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreVec3dTest.cpp


23. Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreMat4dTest.cpp 🧪 Tests +2/-2

Migrate to pdmToVariant/pdmFromVariant

Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreMat4dTest.cpp


24. Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreColor3fTest.cpp 🧪 Tests +16/-2

Add variant equality tests for Color3f

Fwk/AppFwk/cafPdmCvf/cafPdmCvf_UnitTests/cafPdmCoreColor3fTest.cpp


25. Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiCheckBoxAndTextEditorTest.cpp 🧪 Tests +7/-7

Migrate to pdmToVariant/pdmFromVariant

Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/cafPdmUiCheckBoxAndTextEditorTest.cpp


26. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_basic_fields.cpp 🧪 Tests +59/-0

Compile-time benchmark for basic field types

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_basic_fields.cpp


27. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_enum_fields.cpp 🧪 Tests +50/-0

Compile-time benchmark for AppEnum types

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_enum_fields.cpp


28. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_container_fields.cpp 🧪 Tests +61/-0

Compile-time benchmark for container types

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_container_fields.cpp


29. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_filepath_fields.cpp 🧪 Tests +52/-0

Compile-time benchmark for FilePath types

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_filepath_fields.cpp


30. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_mixed_fields.cpp 🧪 Tests +70/-0

Compile-time benchmark for mixed field types

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/bench_mixed_fields.cpp


31. Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/CMakeLists.txt ⚙️ Configuration changes +27/-0

Build configuration for compile benchmarks

Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench/CMakeLists.txt


32. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt ⚙️ Configuration changes +1/-1

Update header file reference in build

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt


33. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt ⚙️ Configuration changes +1/-0

Add new field traits test file

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt


34. CMakeLists.txt ⚙️ Configuration changes +5/-0

Add compile benchmark and CVF unit tests

CMakeLists.txt


35. Fwk/CMakeLists.txt ⚙️ Configuration changes +3/-0

Add compile benchmark subdirectory

Fwk/CMakeLists.txt


36. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.h 🐞 Bug fix +1/-2

Add virtual destructor and remove includes

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.h


37. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp 🐞 Bug fix +4/-0

Add virtual destructor implementation

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp


38. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmOptionItemInfo.cpp 🐞 Bug fix +2/-0

Add missing QIcon include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmOptionItemInfo.cpp


39. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp 🐞 Bug fix +2/-0

Add missing cafAssert include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp


40. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp 🐞 Bug fix +1/-0

Add missing cafPdmObjectHandle include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp


41. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp 🐞 Bug fix +2/-0

Add missing QIcon include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp


42. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItemInfo.cpp 🐞 Bug fix +2/-0

Add missing QIcon include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItemInfo.cpp


43. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.h


44. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h


45. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUi3dObjectEditorHandle.h 🐞 Bug fix +2/-0

Add forward declaration for PdmUiFieldHandle

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUi3dObjectEditorHandle.h


46. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h 🐞 Bug fix +3/-0

Add missing includes and forward declarations

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h


47. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItemInfo.h 🐞 Bug fix +2/-0

Add missing QColor include

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItemInfo.h


48. Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h 🐞 Bug fix +2/-0

Add forward declarations for PDM classes

Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.h


49. Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.h


50. Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h 🐞 Bug fix +1/-0

Add forward declaration for PdmObjectHandle

Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.h


51. Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h 🐞 Bug fix +2/-0

Add missing QRect include and forward declaration

Fwk/AppFwk/cafUserInterface/cafPdmUiTreeAttributes.h


52. Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h 🐞 Bug fix +1/-1

Add missing include and remove forward declaration

Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h


53. ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp


54. ApplicationLibCode/Application/Tools/RiaOptionItemFactory.h 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

ApplicationLibCode/Application/Tools/RiaOptionItemFactory.h


55. ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h 🐞 Bug fix +1/-0

Add missing cafPdmOptionItemInfo include

ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.h


56. Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp 🐞 Bug fix +2/-0

Add missing cafAssert include

Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp


57. Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp 🐞 Bug fix +4/-0

Add file cleanup in test teardown

Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp


58. Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp 🐞 Bug fix +1/-0

Add missing cafFilePath include

Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp


59. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp Additional files +1/-0

...

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp


60. Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h Additional files +2/-2

...

Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldSpecialization.h


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Apr 4, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (2) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Action required

1. Missing Vec3d traits include 🐞 Bug ≡ Correctness
Description
RicStoreUserDefinedCameraFeature.cpp and RicApplyUserDefinedCameraFeature.cpp call
caf::pdmToVariant/pdmFromVariant for cvf::Vec3d but do not include the header that declares the
cvf::Vec3d overloads, which will likely fail to compile. Even if another header incidentally
provides the generic template, it would store cvf::Vec3d as a metatype QVariant instead of the
intended QString format, breaking persistence via QSettings.
Code

ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp[R107-114]

+        QVariant eyeVariant = caf::pdmToVariant( eye );
        settings.setValue( RicStoreUserDefinedCameraFeature::eyeName(), eyeVariant );

-        QVariant vrpVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( vrp );
+        QVariant vrpVariant = caf::pdmToVariant( vrp );
        settings.setValue( RicStoreUserDefinedCameraFeature::viewReferencePointName(), vrpVariant );

-        QVariant upVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( up );
+        QVariant upVariant = caf::pdmToVariant( up );
        settings.setValue( RicStoreUserDefinedCameraFeature::upName(), upVariant );
Evidence
The modified camera feature files include only application/view headers plus QSettings/cvfCamera,
and then call caf::pdmToVariant / caf::pdmFromVariant. The cvf::Vec3d overloads are defined in
cafPdmCoreVec3d.h; without including it, the functions/overloads are not visible at the call site
(compile error), and QSettings would not receive the intended string-based QVariant representation.

ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp[19-33]
ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp[94-115]
ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp[19-32]
ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp[83-100]
Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h[42-66]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`RicStoreUserDefinedCameraFeature.cpp` and `RicApplyUserDefinedCameraFeature.cpp` now call `caf::pdmToVariant` / `caf::pdmFromVariant` for `cvf::Vec3d`, but they don’t include the header that declares the `cvf::Vec3d` overloads. This is likely a compile error (unresolved symbol at compile-time), and it also risks changing the persisted QSettings format if the generic template overload is chosen.

### Issue Context
The `cvf::Vec3d` overloads live in `Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h` and convert to/from a `QString`-backed `QVariant`, which is appropriate for `QSettings`.

### Fix Focus Areas
- ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp[19-33]
- ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp[19-32]

### Suggested change
Add:
```cpp
#include "cafPdmCoreVec3d.h"
```
(in both translation units, or in a common header they both include) so the intended overloads are visible.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. CMake adds cafPdm_CompileBench 📘 Rule violation ⚙ Maintainability
Description
This PR modifies CMake build configuration by adding a new compile-time benchmark
subdirectory/target, which can impact CI builds and packaging. The task description does not
explicitly request CI/CD/build configuration changes.
Code

CMakeLists.txt[R992-994]

+  # Compile-time benchmark
+  add_subdirectory(Fwk/AppFwk/cafProjectDataModel/cafPdm_CompileBench)
+
Evidence
Compliance ID 2 prohibits CI/CD configuration changes unless explicitly requested; the PR adds new
build subdirectories/targets via add_subdirectory(...), which changes the build configuration and
can affect CI outcomes.

CLAUDE.md
CMakeLists.txt[992-994]
Fwk/CMakeLists.txt[61-63]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
CMake build configuration was modified to always add the `cafPdm_CompileBench` subdirectory/target, which may be considered a CI/CD/build-config change not explicitly requested.

## Issue Context
This can affect CI build time and build outputs; if this benchmark is intended for local benchmarking only, it should be opt-in (or removed from default build/test aggregation).

## Fix Focus Areas
- CMakeLists.txt[992-994]
- Fwk/CMakeLists.txt[61-63]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. BaseTest.ReadWrite deletes files 📘 Rule violation ☼ Reliability
Description
The PR modifies an existing unit test to delete multiple files at the end of the test, which may be
unrelated to the field specialization changes and could hide failures/artifacts used for debugging.
Unrelated test modifications violate the requirement to keep unrelated tests unchanged.
Code

Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp[R742-745]

+
+    QFile::remove( fileName );
+    QFile::remove( fileNameCopy );
+    QFile::remove( "PdmTestFilWithError.xml" );
Evidence
Compliance ID 3 requires avoiding unrelated test modifications; the diff shows new file deletion
calls appended to an existing test without any visible linkage to the pdm specialization/traits
refactor in the shown hunks.

CLAUDE.md
Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp[742-745]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An existing test was modified to remove several files at the end, which may be unrelated to this PR’s core change and can make failures harder to diagnose.

## Issue Context
If cleanup is needed to fix CI flakiness, it should be clearly justified in the PR context (or constrained to files created by this test only).

## Fix Focus Areas
- Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/cafPdmBasicTest.cpp[742-745]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

magnesj and others added 2 commits April 4, 2026 06:49
Inconsistency: pdmToVariant(nullopt) returns an invalid QVariant(), but
pdmFromVariant was detecting nullopt via toString().remove('"').isEmpty(),
which is fragile and allocates unnecessarily. Use !v.isValid() to match
the documented convention.
Comment on lines +107 to 114
QVariant eyeVariant = caf::pdmToVariant( eye );
settings.setValue( RicStoreUserDefinedCameraFeature::eyeName(), eyeVariant );

QVariant vrpVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( vrp );
QVariant vrpVariant = caf::pdmToVariant( vrp );
settings.setValue( RicStoreUserDefinedCameraFeature::viewReferencePointName(), vrpVariant );

QVariant upVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( up );
QVariant upVariant = caf::pdmToVariant( up );
settings.setValue( RicStoreUserDefinedCameraFeature::upName(), upVariant );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Missing vec3d traits include 🐞 Bug ≡ Correctness

RicStoreUserDefinedCameraFeature.cpp and RicApplyUserDefinedCameraFeature.cpp call
caf::pdmToVariant/pdmFromVariant for cvf::Vec3d but do not include the header that declares the
cvf::Vec3d overloads, which will likely fail to compile. Even if another header incidentally
provides the generic template, it would store cvf::Vec3d as a metatype QVariant instead of the
intended QString format, breaking persistence via QSettings.
Agent Prompt
### Issue description
`RicStoreUserDefinedCameraFeature.cpp` and `RicApplyUserDefinedCameraFeature.cpp` now call `caf::pdmToVariant` / `caf::pdmFromVariant` for `cvf::Vec3d`, but they don’t include the header that declares the `cvf::Vec3d` overloads. This is likely a compile error (unresolved symbol at compile-time), and it also risks changing the persisted QSettings format if the generic template overload is chosen.

### Issue Context
The `cvf::Vec3d` overloads live in `Fwk/AppFwk/cafPdmCvf/cafPdmCoreVec3d.h` and convert to/from a `QString`-backed `QVariant`, which is appropriate for `QSettings`.

### Fix Focus Areas
- ApplicationLibCode/Commands/3dView/RicStoreUserDefinedCameraFeature.cpp[19-33]
- ApplicationLibCode/Commands/3dView/RicApplyUserDefinedCameraFeature.cpp[19-32]

### Suggested change
Add:
```cpp
#include "cafPdmCoreVec3d.h"
```
(in both translation units, or in a common header they both include) so the intended overloads are visible.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@magnesj magnesj closed this Apr 9, 2026
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.

1 participant