KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
993 stars 66 forks source link

In qt6.7: QDateTime::setTimezone overload breaks compilation #852

Closed Montel closed 5 months ago

Montel commented 5 months ago

Task-Id: 850

Montel commented 5 months ago

I don't have qt6.7 but I added check for using correct method.

ahayzen-kdab commented 5 months ago

Task-Id: 850

Note in GitHub you use things like Closes #850 or Related to #850 :-)

ahayzen-kdab commented 5 months ago

Code looks good, as Qt 6.7 defaults to LegacyBehavior so it's probably not required to have the ifdef. But I think it's likely better to be explicit here and it shows why we needed the C++ method :-)

It would be good if @mystchonky could check if the solves the issue or if one of us can install Qt 6.7 locally.

mystchonky commented 5 months ago

I will gladly test it. Is adding the git tag to cargo.toml for cxx-qt-lib enough? I have added it and I still get the same compilation error as mentioned the original discussion thread.

[dependencies]
cxx = "1.0.115"
cxx-qt = "0.6.0"
cxx-qt-lib = { git = "https://github.com/Montel/cxx-qt.git", branch = "bug_850" }

[build-dependencies]
cxx-qt-build = { version = "0.6.0", features = ["link_qt_object_files"] }

I am on qt 6.7.0beta3

ahayzen-kdab commented 5 months ago

Hmm this changes cxx-qt-lib and cxx-qt-lib-headers you might need to use the override route in cargo.

See https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section

You might need to use something like the following

[patch.crates-io]
cxx-qt-lib = { git = "https://github.com/Montel/cxx-qt.git", branch = "bug_850" }
cxx-qt-lib-headers = { git = "https://github.com/Montel/cxx-qt.git", branch = "bug_850" }
mystchonky commented 5 months ago

I get this compilation error

warning: cxx-qt-lib@0.6.0: src/core/qdatetime.cpp: In function ‘void rust::cxxqtlib1::qdatetimeSetTimeZone(QDateTime&, const QTimeZone&)’:
warning: cxx-qt-lib@0.6.0: src/core/qdatetime.cpp:152:34: error: ‘TransitionResolution’ has not been declared
warning: cxx-qt-lib@0.6.0:   152 |   datetime.setTimeZone(timeZone, TransitionResolution::LegacyBehavior);
warning: cxx-qt-lib@0.6.0:       |                                  ^~~~~~~~~~~~~~~~~~~~
warning: cxx-qt-lib@0.6.0: ToolExecError: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/home/chonky/build/rust/cxx-qt-tutorial/target/debug/build/cxx-qt-lib-217e9a18569f6a25/out/cxxbridge/include" "-I" "/home/chonky/build/rust/cxx-qt-tutorial/target/debug/build/cxx-qt-lib-217e9a18569f6a25/out/cxxbridge/crate" "-I" "/usr/include/qt6/QtCore" "-I" "/usr/include/qt6/QtGui" "-I" "/usr/include/qt6/QtQml" "-I" "/usr/include/qt6" "-I" "/home/chonky/build/rust/cxx-qt-tutorial/target/debug/build/cxx-qt-lib-217e9a18569f6a25/out" "-Wall" "-Wextra" "-std=c++17" "-DCXX_QT_GUI_FEATURE" "-DCXX_QT_QML_FEATURE" "-o" "/home/chonky/build/rust/cxx-qt-tutorial/target/debug/build/cxx-qt-lib-217e9a18569f6a25/out/src/core/qdatetime.o" "-c" "src/core/qdatetime.cpp" with args "c++" did not execute successfully (status code exit status: 1).

error: failed to run custom build command for `cxx-qt-lib v0.6.0 (https://github.com/Montel/cxx-qt.git?branch=bug_850#697755c4)`

Caused by:
  process didn't exit successfully: `/home/chonky/build/rust/cxx-qt-tutorial/target/debug/build/cxx-qt-lib-1b4732144bc2eb72/build-script-build` (exit status: 1)
mystchonky commented 5 months ago

Yeah it compiles and runs now!
image