Skip to content
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

add Qt5/6 compatibility typedef for qHash seed type #4292

Merged
merged 1 commit into from
Sep 19, 2021

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Sep 17, 2021

@github-actions github-actions bot added the ui label Sep 17, 2021
src/util/qhash.h Outdated Show resolved Hide resolved
@Be-ing Be-ing changed the title add Qt5/6 compatibility macro for qHash seed type add Qt5/6 compatibility typedef for qHash seed type Sep 17, 2021
src/util/qhash.h Outdated
@@ -0,0 +1,5 @@
#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
Copy link
Contributor

@uklotzde uklotzde Sep 18, 2021

Choose a reason for hiding this comment

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

Minor nitpick: Please use >= and exchange the arms. The legacy code should be in the 2nd arm. That's how we do it usually, just search for QT_VERSION_CHECK. Will prevent mistakes when removing the conditionals in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow that doesn't build??

#if QT_VERSION_CHECK(6, 0, 0) >= QT_VERSION
typedef size_t qhash_seed_t;
#else
typedef uint qhash_seed_t;
#endif
../src/track/trackref.h:137:18: error: call of overloaded ‘qHash(const TrackId&, qhash_seed_t&)’ is ambiguous
  137 |             qHash(key.getId(), seed);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~

Copy link
Contributor

Choose a reason for hiding this comment

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

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) ;)

@@ -8,6 +8,7 @@
#include <cstdint>

#include "preferences/usersettings.h"
#include "util/qhash.h"
Copy link
Member

Choose a reason for hiding this comment

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

I think we have a compatibility.h header file that we should use instead of adding a new header for each Qt6 class. Or maybe add a single new qtcompat.h file?

Copy link
Contributor

Choose a reason for hiding this comment

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

A single file would pull in many unused Qt dependencies. We already have qtmutex.h.

We should definitely agree on some pattern. Introducing a new subdirectory util/qtcompat with separate header files could also be an option.

@uklotzde
Copy link
Contributor

I guess the the directory is a good start. We can migrate the existing hacks and workarounds step by step. LGTM

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants