Compile issues during Qt5 port
-
Hi all,
I am trying to port a Qt4 app to Qt5. I am not the author of the code, but that code compiles well with Qt4. When compiling against Qt5, I run into the following issue:
@/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static QString Log::getLog()':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:89:34: error: no matching function for call to 'QMutexLocker::QMutexLocker(QBasicAtomicPointer<LogPrivate>)'
QMutexLocker locker(&data);
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:89:34: note: candidate is:
In file included from /usr/include/qt5/QtCore/QMutex:1:0,
from /home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:23,
from /home/quentin/Development/kaffeine-latest/dtvdaemon/log.cpp:1:
/usr/include/qt5/QtCore/qmutex.h:129:21: note: QMutexLocker::QMutexLocker(QBasicMutex)
inline explicit QMutexLocker(QBasicMutex m) QT_MUTEX_LOCK_NOEXCEPT
^
/usr/include/qt5/QtCore/qmutex.h:129:21: note: no known conversion for argument 1 from 'QBasicAtomicPointer<LogPrivate>' to 'QBasicMutex*'
In file included from /home/quentin/Development/kaffeine-latest/dtvdaemon/log.cpp:1:0:
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:90:20: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
return data->buffer;
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static void Log::begin(const char*)':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:107:6: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
data->begin(message);
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static void Log::append(qint64)':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:112:6: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
data->append(value);
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static void Log::append(quint64)':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:117:6: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
data->append(value);
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static void Log::append(const QString&)':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:122:6: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
data->append(string);
^
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp: In static member function 'static void Log::end()':
/home/quentin/Development/kaffeine-latest/dtvdaemon/../src/log.cpp:127:6: error: base operand of '->' has non-pointer type 'QBasicAtomicPointer<LogPrivate>'
data->end();
^
make[2]: *** [dtvdaemon/CMakeFiles/dtvdaemon.dir/log.o] Error 1
make[1]: *** [dtvdaemon/CMakeFiles/dtvdaemon.dir/all] Error 2
make: *** [all] Error 2
11:57:38: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project kaffeine (kit: Desktop)
When executing step 'Make'@Now I understand the type of error this is, but I am a bit rusty in coding and do not understand the difference with Qt4. Here are the source files:
log.cpp: http://pastebin.com/wyEmSwMs
log.h: http://pastebin.com/93FwPRP6Thanks in advance,
Quentin -
QMutexLocker is used to lock a QMutex in RAII-way. So you need to create a QMutex first, and then lock that, instead of &data.
In the code you provided, the mutex locker is initialized on data->mutex, not just data.
-
Thanks sierdzio.
I am progressing with the port but I am now stuck on some QMap issues. I am wondering why it is occurring with Qt5 :
@In file included from /home/quentin/Development/kaffeine-latest/src/backend-vlc/vlcmediawidget.h:24:0,
from /home/quentin/Development/kaffeine-latest/src/backend-vlc/vlcmediawidget.cpp:21:
/home/quentin/Development/kaffeine-latest/src/backend-vlc/../abstractmediawidget.h:109:43: error: field 'metadata' has incomplete type
QMap<MediaWidget::MetadataType, QString> metadata;
^
/home/quentin/Development/kaffeine-latest/src/backend-vlc/../abstractmediawidget.h: In member function 'QMap<MediaWidget::MetadataType, QString> AbstractMediaWidget::getMetadata() const':
/home/quentin/Development/kaffeine-latest/src/backend-vlc/../abstractmediawidget.h:40:63: error: return type 'class QMap<MediaWidget::MetadataType, QString>' is incomplete
QMap<MediaWidget::MetadataType, QString> getMetadata() const { return metadata; }
^
/home/quentin/Development/kaffeine-latest/src/backend-vlc/../abstractmediawidget.h:40:72: error: 'metadata' was not declared in this scope
QMap<MediaWidget::MetadataType, QString> getMetadata() const { return metadata; }
^
/home/quentin/Development/kaffeine-latest/src/backend-vlc/vlcmediawidget.cpp: In member function 'virtual void VlcMediaWidget::updateMetadata()':
/home/quentin/Development/kaffeine-latest/src/backend-vlc/vlcmediawidget.cpp:385:2: error: 'metadata' was not declared in this scope
metadata.clear();
^
make[2]: *** [src/CMakeFiles/kaffeine.dir/backend-vlc/vlcmediawidget.o] Error 1
@
Why does the compiler not accept that type?
The source code is here: http://pastebin.com/pRWUcvpj[UPDATE] Sorry, wrong source code, here is the right one: http://pastebin.com/s2R62y6Y