Skip to content

Commit

Permalink
add Qt5/6 compatibility typedef for qHash seed type
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Sep 18, 2021
1 parent 7b849fb commit 4d5e2e9
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/controllers/midi/midimessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ QDebug operator<<(QDebug debug, MidiOpCode midiOpCode) {
return debug;
}

uint qHash(MidiOpCode key, uint seed) {
qhash_seed_t qHash(MidiOpCode key, qhash_seed_t seed) {
return qHash(static_cast<uint8_t>(key), seed);
}

Expand Down
3 changes: 2 additions & 1 deletion src/controllers/midi/midimessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstdint>

#include "preferences/usersettings.h"
#include "util/compatibility/qhash.h"

// The second value of each OpCode will be the channel number the message
// corresponds to. So 0xB0 is a CC on the first channel, and 0xB1 is a CC
Expand Down Expand Up @@ -96,7 +97,7 @@ enum class MidiOpCode : uint8_t {
SystemReset = 0xFF,
};
QDebug operator<<(QDebug debug, MidiOpCode midiOpCode);
uint qHash(MidiOpCode key, uint seed);
qhash_seed_t qHash(MidiOpCode key, qhash_seed_t seed);

enum class MidiOption : uint16_t {
None = 0x0000,
Expand Down
12 changes: 7 additions & 5 deletions src/effects/defs.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once
#include "util/memory.h"
#include "engine/channelhandle.h"
#include <array>
#include <QSharedPointer>
#include <array>

#include "engine/channelhandle.h"
#include "util/compatibility/qhash.h"
#include "util/memory.h"

enum class EffectEnableState {
Disabled,
Expand All @@ -22,9 +24,9 @@ enum class SignalProcessingStage {
Postfader
};

inline uint qHash(
inline qhash_seed_t qHash(
SignalProcessingStage stage,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(static_cast<uint>(stage), seed);
};

Expand Down
9 changes: 5 additions & 4 deletions src/engine/channelhandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#include "util/assert.h"
#include "util/compatibility/qhash.h"

// ChannelHandle defines a unique identifier for channels of audio in the engine
// (e.g. headphone output, master output, deck 1, microphone 3). Previously we
Expand Down Expand Up @@ -75,9 +76,9 @@ inline QDebug operator<<(QDebug stream, const ChannelHandle& h) {
return stream;
}

inline uint qHash(
inline qhash_seed_t qHash(
const ChannelHandle& handle,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(handle.handle(), seed);
}

Expand Down Expand Up @@ -115,9 +116,9 @@ inline QDebug operator<<(QDebug stream, const ChannelHandleAndGroup& g) {
return stream;
}

inline uint qHash(
inline qhash_seed_t qHash(
const ChannelHandleAndGroup& handleGroup,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(handleGroup.handle(), seed);
}

Expand Down
15 changes: 8 additions & 7 deletions src/preferences/configobject.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#pragma once

#include <QString>
#include <QKeySequence>
#include <QDomNode>
#include <QMap>
#include <QHash>
#include <QKeySequence>
#include <QMap>
#include <QMetaType>
#include <QReadWriteLock>
#include <QString>

#include "util/assert.h"
#include "util/compatibility/qhash.h"
#include "util/debug.h"

// Class for the key for a specific configuration element. A key consists of a
Expand Down Expand Up @@ -59,9 +60,9 @@ inline QDebug operator<<(QDebug stream, const ConfigKey& configKey) {
}

// QHash hash function for ConfigKey objects.
inline uint qHash(
inline qhash_seed_t qHash(
const ConfigKey& key,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(key.group, seed) ^
qHash(key.item, seed);
}
Expand Down Expand Up @@ -95,9 +96,9 @@ inline bool operator!=(const ConfigValue& lhs, const ConfigValue& rhs) {
return !(lhs == rhs);
}

inline uint qHash(
inline qhash_seed_t qHash(
const ConfigValue& key,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(key.value.toUpper(), seed);
}

Expand Down
13 changes: 7 additions & 6 deletions src/soundio/soundmanagerutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QString>
#include <QtDebug>

#include "util/compatibility/qhash.h"
#include "util/fifo.h"
#include "util/types.h"

Expand All @@ -21,9 +22,9 @@ class ChannelGroup {
return (m_channels << 8) |
m_channelBase;
}
friend uint qHash(
friend qhash_seed_t qHash(
const ChannelGroup& group,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(group.hashValue(), seed);
}

Expand Down Expand Up @@ -96,9 +97,9 @@ class AudioPath {
return (m_type << 8) |
m_index;
}
friend uint qHash(
friend qhash_seed_t qHash(
const AudioPath& path,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(path.hashValue(), seed);
}

Expand Down Expand Up @@ -273,9 +274,9 @@ inline bool operator<(const SoundDeviceId& lhs, const SoundDeviceId& rhs) {

Q_DECLARE_METATYPE(SoundDeviceId);

inline uint qHash(
inline qhash_seed_t qHash(
const SoundDeviceId& id,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(id.name, seed) ^
qHash(id.alsaHwDevice, seed) ^
qHash(id.portAudioIndex, seed);
Expand Down
5 changes: 3 additions & 2 deletions src/track/trackref.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "track/trackid.h"
#include "util/compatibility/qhash.h"
#include "util/fileinfo.h"

// A track in the library is identified by a location and an id.
Expand Down Expand Up @@ -128,9 +129,9 @@ std::ostream& operator<<(std::ostream& os, const TrackRef& trackRef);

QDebug operator<<(QDebug debug, const TrackRef& trackRef);

inline uint qHash(
inline qhash_seed_t qHash(
const TrackRef& key,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(
key.getLocation(), seed) ^
qHash(key.getId(), seed);
Expand Down
7 changes: 7 additions & 0 deletions src/util/compatibility/qhash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
typedef size_t qhash_seed_t;
#else
typedef uint qhash_seed_t;
#endif
14 changes: 6 additions & 8 deletions src/util/db/dbid.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#pragma once


#include <functional>
#include <ostream>
#include <utility>

#include <QString>
#include <QVariant>
#include <QtDebug>
#include <functional>
#include <ostream>
#include <utility>

#include "util/assert.h"

#include "util/compatibility/qhash.h"

// Base class for ID values of objects that are stored in the database.
//
Expand Down Expand Up @@ -102,9 +100,9 @@ class DbId {
return debug << dbId.m_value;
}

friend uint qHash(
friend qhash_seed_t qHash(
const DbId& dbId,
uint seed = 0) {
qhash_seed_t seed = 0) {
return qHash(dbId.m_value, seed);
}

Expand Down

0 comments on commit 4d5e2e9

Please sign in to comment.