-
-
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
[auth][bugfix] Auth DB migrate #5546
Conversation
src/app/qgsversionmigration.cpp
Outdated
QgsError authDbErrors = migrateAuthDb(); | ||
if ( !authDbErrors.isEmpty() ) | ||
{ | ||
for ( const auto &err : authDbErrors.messageList( ) ) |
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.
you'll need to make a const temporary copy of the list or stick to Q_FOREACH. Same above.
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.
@m-kuhn even if messageList
is const (or at least that was it was mean to be) ?
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 thought so, but might really be that the const works here based on some research I did right now.
Even if this works, I would prefer to have this copy in place. The reason is, that if this is done wrong we have an expensive detach and detecting this in code reviews is impossible if at the place where it's used no copy is taken.
The alternative would be that someone gets ground truth for the iterate-on-const-return first and then modifies the whole code-source accordingly so we can assume this while reviewing.
src/app/qgsversionmigration.cpp
Outdated
else | ||
{ | ||
QgsDebugMsg( QStringLiteral( "OLD AUTH DB FILE %1" ).arg( oldAuthDbFilePath ) ); | ||
QgsDebugMsg( QStringLiteral( "NEW AUTH DB FILE %1" ).arg( newAuthDbFilePath ) ); |
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.
That should probably stay quiet, there's enough info below I guess
src/core/qgserror.h
Outdated
* \brief messageList return the list of current error messages | ||
* \return current list of error messages | ||
*/ | ||
const QList<QgsErrorMessage> messageList() { return mMessageList; } |
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.
That const here should be moved to the end of the signature.
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.
Are you sure that we don't want to "add" a const after the signature?
I wanted the getter to return a const list too, to feed the range loops.
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.
Yes, the idea was to add one after the signature. And to remove the one before, but that's already discussed above.
src/core/qgserror.h
Outdated
@@ -132,7 +132,7 @@ class CORE_EXPORT QgsError | |||
* \brief messageList return the list of current error messages | |||
* \return current list of error messages | |||
*/ | |||
const QList<QgsErrorMessage> messageList() { return mMessageList; } | |||
const QList<QgsErrorMessage> messageList() const { return mMessageList; } |
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.
Thanks @elpaso
Did you review if the const for the return type serves a purpose? I am asking because so far we always asked devs to drop it and it would be nice to have this done consistently throughout the codebase.
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 was convinced that returning a const here allowed you to range loop iterate on the list without the need to make a const copy of it. But I might be wrong. Let me check if I can get an answer from a debugger.
Btw, I'm now making a const copy as you requested so this const is now unnecessary, but I'm still convinced that if the const copy is not needed we should not make it.
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 assume even if we don't explicitly make a copy, a temporary for return will be created implicitly anyway, but looking forward to your findings 👍
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.
const QList<QgsErrorMessage> errorList( stylesErrors.messageList( ) );
for ( const auto &err : errorList )
{
errors.append( err );
}
for ( const auto &err : stylesErrors.messageList( ) )
{
errors.append( err );
}
@m-kuhn what I've found is that the instance address or err
in the two loops is exactly the same when the messageList
returns a const, but it is different if I remove the const from the signature (the one in front of it).
I think we can conclude that returning a const list allows to range loop iterate without the need to make a const copy of the list.
Btw, I guess you are right about the temporary (should we return a reference?) but to my limited understanding what matters here are the instances in the list, that are not copied, not the container itself.
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.
Might be just my understanding:
What that means is, that if you compile with your compiler it actually does make a difference. And this might indeed be backed up by the C++ standard (from C++0x on).
What this also means is, that with the const copy of the list we are always on the safe side, since
... what matters here are the instances in the list, that are not copied, not the container itself.
Unless of course we modify all our return values from QList<X>
to const QList<X>
, then we will also be on the safe side with the other approach. But only for QGIS internal functions, I think the whole Qt codebase returns non-const lists.
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.
no problems to remove the first const if that's the "standard" way for Qt to return lists.
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 checked with Qt upstream, that's the response:
Making returned containers const inhibits move semantics, because const rvalues do not bind to the mutable rvalue references that move constructors and move assignment operators use.
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.
Thanks. This looks fine to me logic wise. Thanks for adding the merge error message logic for me as well.
Thanks a lot of tackling this one.
…On Tue, Nov 7, 2017 at 5:26 PM, Alessandro Pasotti ***@***.*** > wrote:
Merged #5546 <#5546>.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#5546 (comment)>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAXS3L2TeJ5-JbB4eiJieKWQeMhGGhWtks5s0AYIgaJpZM4QTL0u>
.
|
Thank you for taking care of our beloved users :) |
Description
Add a migration step that copies the qgis authentication DB to the new profile folder.
Fixes https://issues.qgis.org/issues/17403 (Authentication DB is not migrated from 2 to 3)