-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Qt6] Get rid of deprecated QVariant::Type #57272
Conversation
96c9885
to
ea70afd
Compare
e1064ab
to
fc27fcd
Compare
Everything is green now, anyone willing to review this beast 😬 ? |
@troopa81 I'm part way through a review. Nothing scary so far, but I want to be extra cautious here! It's looking great so far |
Great to hear, thanks!! |
@@ -130,12 +130,12 @@ void QgsProcessingAggregatePanelWidget::setValue( const QVariant &value ) | |||
{ | |||
const QVariantMap map = field.toMap(); | |||
const QgsField f( map.value( QStringLiteral( "name" ) ).toString(), | |||
static_cast< QVariant::Type >( map.value( QStringLiteral( "type" ), QVariant::Invalid ).toInt() ), | |||
map.value( QStringLiteral( "type_name" ), QVariant::typeToName( static_cast< QVariant::Type >( map.value( QStringLiteral( "type" ), QVariant::Invalid ).toInt() ) ) ).toString(), | |||
static_cast< QMetaType::Type >( map.value( QStringLiteral( "type" ), QgsVariantUtils::createVariant( QMetaType::Type::UnknownType ) ).toInt() ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something has gone wrong here -- the original code wasn't creating a variant, it was using a variant type as the default value from the map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in this case we're not trying to retrieve a variant from the map, we are trying to retrieve an int/enum value. So I think the better version would be something like:
static_cast< QMetaType::Type >( map.value( QStringLiteral( "type" ), static_cast< int >( QMetaType::Type::UnknownType ) ).toInt() )
Otherwise the default value will be an invalid QVariant(), we'll call .toInt() on that and get 0 (since QVariant() can't be converted to int, but we aren't checking whether the conversion succeeded), and then static cast it to QMetaType::Type... which still results in QMetaType::Type::UnknownType, but just via a convulated and tricky to understand path :rofl:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll address this in a follow up, let's get this monster merged before more merge conflicts are introduced!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #57620
@@ -133,12 +133,12 @@ void QgsProcessingFieldMapPanelWidget::setValue( const QVariant &value ) | |||
{ | |||
const QVariantMap map = field.toMap(); | |||
QgsField f( map.value( QStringLiteral( "name" ) ).toString(), | |||
static_cast< QVariant::Type >( map.value( QStringLiteral( "type" ), QVariant::Invalid ).toInt() ), | |||
map.value( QStringLiteral( "type_name" ), QVariant::typeToName( static_cast< QVariant::Type >( map.value( QStringLiteral( "type" ), QVariant::Invalid ).toInt() ) ) ).toString(), | |||
static_cast< QMetaType::Type >( map.value( QStringLiteral( "type" ), QgsVariantUtils::createVariant( QMetaType::Type::UnknownType ) ).toInt() ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something has gone wrong here too -- there should be no createVariant call here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
@troopa81 ok, just a couple of small changes. Which is amazing given the size of this changeset! Fantastic work here, I can only imagine how painful this was... |
@troopa81 , good job! |
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
532e6ba
to
db44f54
Compare
This PR mainly focus on replacing deprecated QVariant::Type with QMetaType::Type, but I plan also to replace then all QVariant/QMetaType deprecated methods.
There are still things that need to be fixed (Hana provider for starter) but I would like to start discussions before going any further.
These modifications have been partially generated with the following python script.