Fix ADL lookup for cvf pdmToVariant/pdmFromVariant overloads#13848
Merged
Fix ADL lookup for cvf pdmToVariant/pdmFromVariant overloads#13848
Conversation
7ab4968 to
a21fec7
Compare
Move pdmToVariant/pdmFromVariant overloads for cvf::Color3f, Vec3d, Mat4d, and Mat3d from namespace caf to namespace cvf. Templates in cafInternalPdmFieldTypeSpecializations.h use "using caf::pdmToVariant" followed by an unqualified call, so ADL searches the argument's namespace (cvf). With the overloads only in caf, the default template was selected, causing cvf::Color3f to be stored raw in a QVariant instead of as QColor — breaking color field editing and producing QVariant::save warnings. All call sites now use the unqualified "using caf::pdmXxx; pdmXxx(value)" pattern so ADL finds the correct overload without depending on cvf:: as a visible prefix. Add AdlVariantTest to cafPdmCoreColor3fTest.cpp that exercises this exact pattern. Fixes by clang-format
a21fec7 to
ba6bc16
Compare
jonjenssen
reviewed
Apr 8, 2026
Adds caf::toVariant<T> and caf::fromVariant<T> to cafPdmFieldTraits.h as thin wrappers that encapsulate the ADL two-step internally. Client code can now call caf::toVariant(x) directly instead of requiring a using-declaration at every call site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move pdmToVariant/pdmFromVariant overloads for cvf::Color3f, Vec3d, Mat4d, and
Mat3d from namespace caf to namespace cvf. Templates in
cafInternalPdmFieldTypeSpecializations.h use "using caf::pdmToVariant" followed
by an unqualified call, so ADL searches the argument's namespace (cvf). With the
overloads only in caf, the default template was selected, causing cvf::Color3f to
be stored raw in a QVariant instead of as QColor — breaking color field editing
and producing QVariant::save warnings.
Update all explicit caf::pdmToVariant/pdmFromVariant call sites for cvf types in
application code and unit tests to use cvf:: namespace. Add AdlVariantTest to
cafPdmCoreColor3fTest.cpp that exercises the exact template pattern.