nsuke / protobuf-qml

Protocol Buffers and gRPC binding for QML (QtQuick2)
MIT License
54 stars 14 forks source link

Qt 5.8 - Qt 5.9 compilation fail #19

Open wawa19933 opened 7 years ago

wawa19933 commented 7 years ago

Could not compile with Qt 5.9. I found commit in QtQML #https://github.com/qt/qtdeclarative/commit/8a6383775a301c8dd8c917a936655c534932a726 which deprecates QQmlContextWrapper

So, they changed corresponding API in Qt 5.8...

FAILED: lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o 
/usr/bin/c++  -DPROTOBUF_QML_EXPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -Dprotobuf_qml_core_EXPORTS -Ilib/protobuf -I../../lib/protobuf -Ilib/protobuf/protobuf-qml-core_autogen/include -I../../compiler -isystem /usr/include/qt/QtQml/5.9.0 -isystem /usr/include/qt/QtQml/5.9.0/QtQml -isystem /usr/include/qt/QtNetwork/5.9.0 -isystem /usr/include/qt/QtNetwork/5.9.0/QtNetwork -isystem /usr/include/qt/QtCore/5.9.0 -isystem /usr/include/qt/QtCore/5.9.0/QtCore -isystem ../../build/deps/Release/include -I../../lib -isystem /usr/include/qt -isystem /usr/include/qt/QtQuick -isystem /usr/include/qt/QtQml -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/qt/QtGui -Wno-inconsistent-missing-override -fdiagnostics-color -Wall -Wextra -Wno-unused-parameter -O3 -DNDEBUG -fPIC   -fPIC -std=gnu++11 -MD -MT lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o -MF lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o.d -o lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o -c ../../lib/protobuf/qml/v4/v4util.cpp
../../lib/protobuf/qml/v4/v4util.cpp:3:10: fatal error: private/qqmlcontextwrapper_p.h: No such file or directory
 #include <private/qqmlcontextwrapper_p.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[67/141] Building CXX object lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/conversions.cpp.o
ninja: build stopped: subcommand failed.
onto commented 6 years ago

On 5.8.1 it can be solved by at top of file:

#if (QT_VERSION <= QT_VERSION_CHECK(5, 8, 0))
#include <QtQml/private/qqmlcontextwrapper_p.h>
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 8, 1))
#include <QtQml/private/qv4qmlcontext_p.h>
#endif

and replace packCallbackObject function by

#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 1))
static ReturnedValue qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope)
{
  Scope valueScope(v4);

  Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->allocObject<QmlContextWrapper>(ctxt, scope));
  return w.asReturnedValue();
}
#endif

ReturnedValue packCallbackObject(ExecutionEngine* v4, const Value& callback) {
  Scope scope(v4);
  ScopedObject o(scope, v4->newObject());
#if (QT_VERSION <= QT_VERSION_CHECK(5, 8, 0))
  ScopedValue ctx(scope, QmlContextWrapper::qmlScope(scope.engine, callingQmlContext(v4), 0));
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 8, 1))
  ScopedValue ctx(scope, qmlScope(scope.engine, callingQmlContext(v4), 0));
#endif
  o->put(ScopedString(scope, v4->newString(QStringLiteral("CallingContext"))),
         ctx);
  ScopedFunctionObject cb(scope, callback);
  o->put(ScopedString(scope, v4->newString(QStringLiteral("CallbackObject"))),
         cb);
  return o->asReturnedValue();
}

but i can`t find solution for 5.9.1 for now

djahma commented 5 years ago

Similar trouble with Qt 5.10.1


gman@thinkpad:~/Downloads/protobuf-qml-master$ ninja -C out/Release
ninja: Entering directory `out/Release'
[42/155] Automatic moc for target protobuf-qml
Generating moc_protobuf_plugin.cpp
[43/155] Automatic moc for target TestConvert
Generating test_convert.moc
[44/155] Automatic moc for target protobuf-qml-core
Generating moc_buffer.cpp
Generating moc_descriptors.cpp
Generating moc_file.cpp
Generating moc_memory.cpp
Generating moc_method.cpp
Generating moc_server_method.cpp
Generating moc_descriptor.cpp
[46/155] Automatic moc for target grpc-qml
Generating moc_base.cpp
Generating moc_credentials.cpp
Generating moc_grpc_plugin.cpp
Generating moc_reader.cpp
Generating moc_reader_writer.cpp
Generating moc_server.cpp
Generating moc_server_bidi.cpp
Generating moc_server_credentials.cpp
Generating moc_server_reader.cpp
Generating moc_server_unary.cpp
Generating moc_server_writer.cpp
Generating moc_unary.cpp
Generating moc_writer.cpp
[55/155] Building CXX object lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o
FAILED: lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o 
/usr/bin/c++   -DPROTOBUF_QML_EXPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -Dprotobuf_qml_core_EXPORTS -Ilib/protobuf -I../../lib/protobuf -I../../compiler -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork/5.10.1/QtNetwork -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore/5.10.1/QtCore -isystem ../../build/deps/Release/include -I../../lib -isystem /home/gman/Qt/5.10.1/gcc_64/include -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQuick -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore -isystem /home/gman/Qt/5.10.1/gcc_64/./mkspecs/linux-g++ -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtGui -Wno-inconsistent-missing-override -fdiagnostics-color -Wall -Wextra -Wno-unused-parameter -O3 -DNDEBUG -fPIC   -fPIC -std=gnu++11 -MMD -MT lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o -MF lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o.d -o lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/v4util.cpp.o -c ../../lib/protobuf/qml/v4/v4util.cpp
../../lib/protobuf/qml/v4/v4util.cpp:3:42: fatal error: private/qqmlcontextwrapper_p.h: No such file or directory
compilation terminated.
[58/155] Building CXX object lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/descriptor.cpp.o
FAILED: lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/descriptor.cpp.o 
/usr/bin/c++   -DPROTOBUF_QML_EXPORT -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -Dprotobuf_qml_core_EXPORTS -Ilib/protobuf -I../../lib/protobuf -I../../compiler -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork/5.10.1/QtNetwork -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore/5.10.1 -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore/5.10.1/QtCore -isystem ../../build/deps/Release/include -I../../lib -isystem /home/gman/Qt/5.10.1/gcc_64/include -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQuick -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtQml -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtNetwork -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtCore -isystem /home/gman/Qt/5.10.1/gcc_64/./mkspecs/linux-g++ -isystem /home/gman/Qt/5.10.1/gcc_64/include/QtGui -Wno-inconsistent-missing-override -fdiagnostics-color -Wall -Wextra -Wno-unused-parameter -O3 -DNDEBUG -fPIC   -fPIC -std=gnu++11 -MMD -MT lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/descriptor.cpp.o -MF lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/descriptor.cpp.o.d -o lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/v4/descriptor.cpp.o -c ../../lib/protobuf/qml/v4/descriptor.cpp
../../lib/protobuf/qml/v4/descriptor.cpp: In member function 'void protobuf::qml::SerializeTask::onDone(const QByteArray&)':
../../lib/protobuf/qml/v4/descriptor.cpp:744:17: error: no matching function for call to 'QV4::Object::call(QV4::ScopedCallData&)'
   cb->call(cdata);
                 ^
In file included from /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4arraybuffer_p.h:53:0,
                 from ../../lib/protobuf/qml/v4/v4util.h:5,
                 from ../../lib/protobuf/qml/v4/descriptor.cpp:2:
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:444:17: note: candidate: void QV4::Object::call(QV4::Scope&, QV4::CallData*) const
     inline void call(Scope &scope, CallData *d) const
                 ^
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:444:17: note:   candidate expects 2 arguments, 1 provided
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:448:17: note: candidate: static void QV4::Object::call(const QV4::Managed*, QV4::Scope&, QV4::CallData*)
     static void call(const Managed *m, Scope &scope, CallData *);
                 ^
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:448:17: note:   candidate expects 3 arguments, 1 provided
../../lib/protobuf/qml/v4/descriptor.cpp: In member function 'void protobuf::qml::ParseTask::onDone()':
../../lib/protobuf/qml/v4/descriptor.cpp:779:17: error: no matching function for call to 'QV4::Object::call(QV4::ScopedCallData&)'
   cb->call(cdata);
                 ^
In file included from /home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4arraybuffer_p.h:53:0,
                 from ../../lib/protobuf/qml/v4/v4util.h:5,
                 from ../../lib/protobuf/qml/v4/descriptor.cpp:2:
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:444:17: note: candidate: void QV4::Object::call(QV4::Scope&, QV4::CallData*) const
     inline void call(Scope &scope, CallData *d) const
                 ^
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:444:17: note:   candidate expects 2 arguments, 1 provided
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:448:17: note: candidate: static void QV4::Object::call(const QV4::Managed*, QV4::Scope&, QV4::CallData*)
     static void call(const Managed *m, Scope &scope, CallData *);
                 ^
/home/gman/Qt/5.10.1/gcc_64/include/QtQml/5.10.1/QtQml/private/qv4object_p.h:448:17: note:   candidate expects 3 arguments, 1 provided
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-inconsistent-missing-override'
[60/155] Building CXX object lib/protobuf/CMakeFiles/protobuf-qml-core.dir/qml/server_method.cpp.o
ninja: build stopped: subcommand failed.
gman@thinkpad:~/Downloads/protobuf-qml-master$ 
`
onto commented 5 years ago

@djahma Because there a lot of changes in Qt internals since 5.7