Skip to content

Commit

Permalink
Fixup build with qt > 5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Aug 18, 2024
1 parent 43ec16f commit 9617e4f
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 86 deletions.
4 changes: 2 additions & 2 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ LIBDBUSQEVENTLOOP = $${PWD}/libdbus-qeventloop
LIBRESOURCEQT = $${PWD}/libresourceqt
LIBMEDIAOVERRIDESQT = $${PWD}/libmediaoverridesqt

RESOURCEQTLIB = -L$${LIBRESOURCEQT}/build -lresourceqt5
DBUSQEVENTLOOPLIB = -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop-qt5
RESOURCEQTLIB = -L$${LIBRESOURCEQT}/build -lresourceqt$${QT_MAJOR_VERSION}
DBUSQEVENTLOOPLIB = -L$${LIBDBUSQEVENTLOOP}/build -ldbus-qeventloop-qt$${QT_MAJOR_VERSION}

PUBLIC_INCLUDE = $${LIBRESOURCEQT}/include/

2 changes: 1 addition & 1 deletion libdbus-qeventloop/dbusconnectioneventloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ dbus_bool_t DBUSConnectionEventLoop::addWatch(DBusWatch *watch, void *data)
loop->connect(watcher.write, SIGNAL(activated(int)), SLOT(writeSocket(int)));
}

loop->watchers.insertMulti(fd, watcher);
loop->watchers.insert(fd, watcher);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions libdbus-qeventloop/libdbus-qeventloop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################

include(../common.pri)
TARGET = dbus-qeventloop-qt5
TARGET = dbus-qeventloop-qt$${QT_MAJOR_VERSION}
TEMPLATE = lib
DESTDIR = build
MOC_DIR = .moc
Expand All @@ -42,14 +42,14 @@ INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $$INSTALLBASE/include

QMAKE_PKGCONFIG_NAME = libdbus-qeventloop5
QMAKE_PKGCONFIG_NAME = libdbus-qeventloop$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = D-Bus - QEventloop binding
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = dbus-1
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libdbus-qeventloop5
QMAKE_PKGCONFIG_FILE = libdbus-qeventloop$${QT_MAJOR_VERSION}

INSTALLS = target headers

12 changes: 6 additions & 6 deletions libmediaoverridesqt/libmediaoverridesqt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(../common.pri)
TEMPLATE = lib
TARGET = mediaoverridesqt5
TARGET = mediaoverridesqt$${QT_MAJOR_VERSION}
DESTDIR = build
DEPENDPATH += .
INCLUDEPATH += .
Expand Down Expand Up @@ -28,16 +28,16 @@ QMAKE_DISTCLEAN += -r moc build
headers.files = $${PUBLIC_HEADERS}
INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $${INSTALLBASE}/include/resource/qt5/policy
headers.path = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}/policy

QMAKE_PKGCONFIG_NAME = libmediaoverridesqt5
QMAKE_PKGCONFIG_NAME = libmediaoverridesqt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = Maemo playback manager Qt API
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt5
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = Qt5DBus
QMAKE_PKGCONFIG_REQUIRES = Qt$${QT_MAJOR_VERSION}DBus
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libmediaoverridesqt5
QMAKE_PKGCONFIG_FILE = libmediaoverridesqt$${QT_MAJOR_VERSION}

INSTALLS = target headers

8 changes: 8 additions & 0 deletions libresourceqt/include/policy/resource-set.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ USA.
#include <stdarg.h>
#include <stdio.h>

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
#include <QRecursiveMutex>
#endif

class ResourceSetPrivate;


Expand Down Expand Up @@ -414,7 +418,11 @@ class ResourceSet: public QObject
bool haveAudioProperties;
bool inAcquireMode;
QList<requestType> requestQ;
#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
QRecursiveMutex reqMutex;
#else
QMutex reqMutex;
#endif
bool ignoreQ;
ResourceSetPrivate* d;
bool initialize();
Expand Down
16 changes: 8 additions & 8 deletions libresourceqt/libresourceqt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

include(../common.pri)
TEMPLATE = lib
TARGET = resourceqt5
TARGET = resourceqt$${QT_MAJOR_VERSION}
DESTDIR = build
DEPENDPATH += $${POLICY} src
INCLUDEPATH += $${PUBLIC_INCLUDE} $${LIBDBUSQEVENTLOOP} src
Expand Down Expand Up @@ -55,23 +55,23 @@ PKGCONFIG += dbus-1 libresource
headers.files = $${PUBLIC_HEADERS}
INSTALLBASE = $$[QT_INSTALL_PREFIX]
target.path = $$[QT_INSTALL_LIBS]
headers.path = $${INSTALLBASE}/include/resource/qt5/policy
headers.path = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}/policy

man.files = docs/man
man.path = $${INSTALLBASE}/share
htmldoc.files = docs/html
htmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt5
htmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt$${QT_MAJOR_VERSION}
xmldoc.files = docs/xml
xmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt5
xmldoc.path = $${INSTALLBASE}/share/doc/libresourceqt$${QT_MAJOR_VERSION}

QMAKE_PKGCONFIG_NAME = libresourceqt5
QMAKE_PKGCONFIG_NAME = libresourceqt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESCRIPTION = Maemo resource management Qt API
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt5
QMAKE_PKGCONFIG_INCDIR = $${INSTALLBASE}/include/resource/qt$${QT_MAJOR_VERSION}
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_REQUIRES = dbus-1 libdbus-qeventloop5 libresource Qt5Core
QMAKE_PKGCONFIG_REQUIRES = dbus-1 libdbus-qeventloop$${QT_MAJOR_VERSION} libresource Qt$${QT_MAJOR_VERSION}Core
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_FILE = libresourceqt5
QMAKE_PKGCONFIG_FILE = libresourceqt$${QT_MAJOR_VERSION}

INSTALLS = target headers man htmldoc xmldoc

25 changes: 25 additions & 0 deletions libresourceqt/src/resource-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ USA.
#include <dbus/dbus.h>
#include <res-msg.h>

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
#include <QRecursiveMutex>
#endif

Q_LOGGING_CATEGORY(lcResourceQt, "resourceQt", QtWarningMsg)

using namespace ResourcePolicy;
Expand All @@ -32,7 +36,11 @@ static QMultiMap<resconn_t *, ResourceEngine *> engineMap;
resconn_t *ResourceEngine::libresourceConnection = NULL;
quint32 ResourceEngine::libresourceUsers = 0;

#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
static QRecursiveMutex mutex;
#else
static QMutex mutex(QMutex::Recursive);
#endif

static inline quint32 allResourcesToBitmask(const ResourceSet *resourceSet);
static inline quint32 optionalResourcesToBitmask(const ResourceSet *resourceSet);
Expand Down Expand Up @@ -254,6 +262,7 @@ static void handleAdviceMessage(resmsg_t *message, resset_t *libresourceSet, voi
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
QMutexLocker locker(&mutex);

if (NULL == libresourceSet->userdata) {
qCDebug(lcResourceQt) << QString("IGNORING advice, no context");
return;
Expand Down Expand Up @@ -556,7 +565,11 @@ bool ResourceEngine::releaseResources()
bool ResourceEngine::updateResources()
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));
message.record.type = RESMSG_UPDATE;
Expand Down Expand Up @@ -591,7 +604,11 @@ bool ResourceEngine::registerAudioProperties(const QString &audioGroup, quint32
const QString &name, const QString &value)
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));
QByteArray groupBa, nameBa, valueBa;
Expand Down Expand Up @@ -633,7 +650,11 @@ bool ResourceEngine::registerAudioProperties(const QString &audioGroup, quint32
bool ResourceEngine::registerVideoProperties(quint32 pid)
{
qCDebug(lcResourceQt, "ResourceEngine(%d)::%s() - **************** locking....", identifier, __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));

Expand All @@ -660,7 +681,11 @@ bool ResourceEngine::registerVideoProperties(quint32 pid)
static void connectionIsUp(resconn_t *connection)
{
qCDebug(lcResourceQt, "**************** %s() - locking....", __FUNCTION__);
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QMutexLocker locker(&mutex);
#else
mutex.lock();
#endif

qCDebug(lcResourceQt) << QString("connection is up");

Expand Down
13 changes: 11 additions & 2 deletions libresourceqt/src/resource-set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ USA.
*************************************************************************/
#include <policy/resource-set.h>
#include "resource-engine.h"

using namespace ResourcePolicy;

static quint32 resourceSetId=1;
Expand All @@ -35,7 +36,11 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent,
audioResource(NULL), autoRelease(initialAutoRelease),
alwaysReply(initialAlwaysReply), initialized(false), pendingAcquire(false),
pendingUpdate(false), pendingAudioProperties(false), pendingVideoProperties(false),
inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false)
inAcquireMode(false),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
reqMutex(QMutex::Recursive),
#endif
ignoreQ(false)
{
identifier = resourceSetId++;
memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes);
Expand All @@ -46,7 +51,11 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent)
audioResource(NULL), autoRelease(false),
alwaysReply(false), initialized(false), pendingAcquire(false),
pendingUpdate(false), pendingAudioProperties(false), pendingVideoProperties(false),
inAcquireMode(false), reqMutex(QMutex::Recursive), ignoreQ(false)
inAcquireMode(false),
#if (QT_VERSION < QT_VERSION_CHECK(5,14,0))
reqMutex(QMutex::Recursive),
#endif
ignoreQ(false)
{
identifier = resourceSetId++;
memset(resourceSet, 0, sizeof(Resource *)*NumberOfTypes);
Expand Down
Loading

0 comments on commit 9617e4f

Please sign in to comment.