Skip to content

Commit

Permalink
QtJambi 6.5.1 release
Browse files Browse the repository at this point in the history
issue #158
issue #153
issue #152
issue #151
issue #150
issue #149
issue #148
issue #147
  • Loading branch information
omix committed May 25, 2023
1 parent 13102c3 commit 0fbd3fe
Show file tree
Hide file tree
Showing 82 changed files with 3,514 additions and 2,278 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Make yourself familiar with [developing applications with QtJambi](www/How-to-de

### Requirements
* [Apache Ant](https://ant.apache.org/) (min. 1.10.x)
* Java Development Kit (e.g. [OpenJDK](https://adoptopenjdk.net/), tested with Java 1.8 and 18)
* Java Development Kit (e.g. [OpenJDK](https://adoptopenjdk.net/), tested with Java 1.8 and 20)
* Qt 5.15 or 6.x (using the Qt Online Installer)
* Minimum required Qt modules: QtCore, QtQml, QtNetwork, QtConcurrent and QtXml
* C++ compiler and make (Gcc, Clang, MSVC2019)
Expand All @@ -57,7 +57,7 @@ This saves compilation time. Although QtJambi build process requires the availab

`> set PATH=...\apache-ant-1.10.3\bin;%PATH%`

`> set QTDIR=C:\Qt\6.5.0\msvc2019_64`
`> set QTDIR=C:\Qt\6.5.1\msvc2019_64`

#### Pre-Build Steps On Linux and macOS

Expand All @@ -67,9 +67,9 @@ This saves compilation time. Although QtJambi build process requires the availab

`> export JAVA_HOME_TARGET=path to your java jdk`

`> export QTDIR=/opt/Qt/6.5.0/gcc_64` on Linux
`> export QTDIR=/opt/Qt/6.5.1/gcc_64` on Linux

`> export QTDIR=/opt/Qt/6.5.0/macos` on macOS
`> export QTDIR=/opt/Qt/6.5.1/macos` on macOS

#### Building Bindings

Expand All @@ -92,11 +92,11 @@ This saves compilation time. Although QtJambi build process requires the availab
After building QtJambi for the running operation system you can additionally cross-compile QtJambi for other platforms.
For instance if you want to build for Android use the following command (on Windows):

`> ant -Dqmake=C:\Qt\6.5.0\android_x86_64\bin\qmake.bat library.native`
`> ant -Dqmake=C:\Qt\6.5.1\android_x86_64\bin\qmake.bat library.native`

or if you want to build for Linux arm:

`> ant -Dqmake=/opt/Qt/6.5.0/arm-gnueabi/bin/qmake library.native`
`> ant -Dqmake=/opt/Qt/6.5.1/arm-gnueabi/bin/qmake library.native`

Just specify the third-platform cross-compiled qmake with `-Dqmake=path`.

Expand All @@ -115,7 +115,7 @@ to your project:
<version>$VERSION</version>
</dependency>
```
(exchange `$VERSION` either by `5.15.14` or by `6.5.0`).
(exchange `$VERSION` either by `5.15.15` or by `6.5.1`).

Otherwise, download QtJambi JAR file from [Maven Central Repository](https://search.maven.org/artifact/io.qtjambi/qtjambi/).

Expand All @@ -135,7 +135,7 @@ public class Test {
Compile the file:

``` powershell
javac -cp qtjambi-6.5.0.jar Test.java
javac -cp qtjambi-6.5.1.jar Test.java
```

### Execute Example
Expand All @@ -154,19 +154,19 @@ In case your Linux distribution provides Qt (of correct version) as system libra
The example program can be executed this way on Windows:

``` powershell
java -cp qtjambi-6.5.0.jar;. -Djava.library.path=C:\Qt\6.5.0\msvc2019_64\bin Test
java -cp qtjambi-6.5.1.jar;. -Djava.library.path=C:\Qt\6.5.1\msvc2019_64\bin Test
```

On Linux it looks this way:

``` bash
java -cp qtjambi-6.5.0.jar:. -Djava.library.path=<path to>/Qt/6.5.0/gcc_64/lib Test
java -cp qtjambi-6.5.1.jar:. -Djava.library.path=<path to>/Qt/6.5.1/gcc_64/lib Test
```

On macOS you additionally need to use the start parameter -XstartOnFirstThread:

``` bash
java -cp qtjambi-6.5.0.jar:. -Djava.library.path=<path to>/Qt/6.5.0/macos/lib -XstartOnFirstThread Test
java -cp qtjambi-6.5.1.jar:. -Djava.library.path=<path to>/Qt/6.5.1/macos/lib -XstartOnFirstThread Test
```

In general, you can start learning how to use Qt in Java [as it is introduced for C++](https://doc.qt.io/qt-6/gettingstarted.html#create-your-first-applications).
Expand Down
3 changes: 0 additions & 3 deletions src/cpp/QtJambi/containeraccess_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,9 +1299,6 @@ void AutoListAccess::remove(JNIEnv *, void* container, jint index, jint n)
Q_ASSERT(n==1);
QListData* p = reinterpret_cast<QListData*>(container);
if (index < 0 || index >= p->size()) {
#if !defined(QT_NO_DEBUG)
qWarning("QList::removeAt(): Index out of range.");
#endif
return;
}
detach(p);
Expand Down
3 changes: 0 additions & 3 deletions src/cpp/QtJambi/containeraccess_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,6 @@ void AutoVectorAccess::remove(JNIEnv *, void* container, jint index, jint n){
QTypedArrayData<char> ** vector = reinterpret_cast<QTypedArrayData<char> **>(container);
QTypedArrayData<char>*& d = *vector;
if (index < 0 || index+n > d->size) {
#if !defined(QT_NO_DEBUG)
qWarning("QVector::removeAt(): Index out of range.");
#endif
return;
}
erase(vector, d->data() + index * m_offset, d->data() + (index+n) * m_offset);
Expand Down
50 changes: 50 additions & 0 deletions src/cpp/QtJambi/containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,10 @@ T& checkedUnref(T* t){

void CoreAPI::initializeQList(JNIEnv *env, jobject object, jclass elementType, QtJambiNativeID elementMetaTypeId, jobject other){
QMetaType& elementMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(elementMetaTypeId));
if(elementMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be type of %1.").arg("QList") QTJAMBI_STACKTRACEINFO );
if(elementMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be type of %1.").arg("QList") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QList") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -1390,6 +1394,12 @@ void CoreAPI::initializeQList(JNIEnv *env, jobject object, jclass elementType, Q

void CoreAPI::initializeQSet(JNIEnv *env, jobject object, jclass elementType, QtJambiNativeID elementMetaTypeId, jobject other){
QMetaType& elementMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(elementMetaTypeId));
if(elementMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be type of %1.").arg("QSet") QTJAMBI_STACKTRACEINFO );
if(elementMetaType.id()==QMetaType::QVariant)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QVariant cannot be type of %1.").arg("QSet") QTJAMBI_STACKTRACEINFO );
if(elementMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be type of %1.").arg("QSet") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QSet") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -1550,6 +1560,10 @@ void CoreAPI::initializeQSet(JNIEnv *env, jobject object, jclass elementType, Qt
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
void CoreAPI::initializeQLinkedList(JNIEnv *env, jobject object, jclass elementType, QtJambiNativeID elementMetaTypeId, jobject other){
QMetaType& elementMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(elementMetaTypeId));
if(elementMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be type of %1.").arg("QLinkedList") QTJAMBI_STACKTRACEINFO );
if(elementMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be type of %1.").arg("QLinkedList") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QLinkedList") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -1700,6 +1714,10 @@ void CoreAPI::initializeQLinkedList(JNIEnv *env, jobject object, jclass elementT

void CoreAPI::initializeQVector(JNIEnv *env, jobject object, jclass elementType, QtJambiNativeID elementMetaTypeId, jobject other){
QMetaType& elementMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(elementMetaTypeId));
if(elementMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be type of %1.").arg("QVector") QTJAMBI_STACKTRACEINFO );
if(elementMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be type of %1.").arg("QVector") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QVector") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -1850,6 +1868,14 @@ void CoreAPI::initializeQVector(JNIEnv *env, jobject object, jclass elementType,
void CoreAPI::initializeQHash(JNIEnv *env, jobject object, jclass keyType, QtJambiNativeID keyMetaTypeId, jclass valueType, QtJambiNativeID valueMetaTypeId, jobject other){
QMetaType& keyMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(keyMetaTypeId));
QMetaType& valueMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(valueMetaTypeId));
if(keyMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be key type of %1.").arg("QHash") QTJAMBI_STACKTRACEINFO );
if(keyMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be key type of %1.").arg("QHash") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be value type of %1.").arg("QHash") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be value type of %1.").arg("QHash") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QHash") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -2009,6 +2035,14 @@ void CoreAPI::initializeQHash(JNIEnv *env, jobject object, jclass keyType, QtJam
void CoreAPI::initializeQMultiHash(JNIEnv *env, jobject object, jclass keyType, QtJambiNativeID keyMetaTypeId, jclass valueType, QtJambiNativeID valueMetaTypeId, jobject other){
QMetaType& keyMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(keyMetaTypeId));
QMetaType& valueMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(valueMetaTypeId));
if(keyMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be key type of %1.").arg("QMultiHash") QTJAMBI_STACKTRACEINFO );
if(keyMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be key type of %1.").arg("QMultiHash") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be value type of %1.").arg("QMultiHash") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be value type of %1.").arg("QMultiHash") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QMultiHash") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -2171,6 +2205,14 @@ void CoreAPI::initializeQMultiHash(JNIEnv *env, jobject object, jclass keyType,
void CoreAPI::initializeQMap(JNIEnv *env, jobject object, jclass keyType, QtJambiNativeID keyMetaTypeId, jclass valueType, QtJambiNativeID valueMetaTypeId, jobject other){
QMetaType& keyMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(keyMetaTypeId));
QMetaType& valueMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(valueMetaTypeId));
if(keyMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be key type of %1.").arg("QMap") QTJAMBI_STACKTRACEINFO );
if(keyMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be key type of %1.").arg("QMap") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be value type of %1.").arg("QMap") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be value type of %1.").arg("QMap") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QMap") QTJAMBI_STACKTRACEINFO );
Expand Down Expand Up @@ -2328,6 +2370,14 @@ void CoreAPI::initializeQMap(JNIEnv *env, jobject object, jclass keyType, QtJamb
void CoreAPI::initializeQMultiMap(JNIEnv *env, jobject object, jclass keyType, QtJambiNativeID keyMetaTypeId, jclass valueType, QtJambiNativeID valueMetaTypeId, jobject other){
QMetaType& keyMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(keyMetaTypeId));
QMetaType& valueMetaType = checkedUnref(QtJambiAPI::objectFromNativeId<QMetaType>(valueMetaTypeId));
if(keyMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be key type of %1.").arg("QMultiMap") QTJAMBI_STACKTRACEINFO );
if(keyMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be key type of %1.").arg("QMultiMap") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::UnknownType)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("QMetaType::UnknownType cannot be value type of %1.").arg("QMultiMap") QTJAMBI_STACKTRACEINFO );
if(valueMetaType.id()==QMetaType::Void)
Java::Runtime::IllegalArgumentException::throwNew(env, QStringLiteral("void cannot be value type of %1.").arg("QMultiMap") QTJAMBI_STACKTRACEINFO );
SuperTypeInfos superTypeInfos = SuperTypeInfos::fromClass(env, env->GetObjectClass(object));
if(superTypeInfos.size()>1)
Java::Runtime::Error::throwNew(env, QStringLiteral("It is not permitted to create a derived type of %1 implementing any Qt interface.").arg("QMultiMap") QTJAMBI_STACKTRACEINFO );
Expand Down
21 changes: 7 additions & 14 deletions src/cpp/QtJambi/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@
template<typename INT>
jobject convertEnumToJavaObject(JNIEnv *env, INT qt_enum, jclass cl, const QString& className, jobject (*resolveEnum)(JNIEnv *, jint, jclass, INT, jstring))
{
#if defined(QTJAMBI_DEBUG_TOOLS)
if(!cl) {
fprintf(stderr, "convertEnumToJavaObject(): %s NOTFOUND\n", qPrintable(className));
fflush(stderr);
qWarning("convertEnumToJavaObject(): %s NOTFOUND", qPrintable(className));
}
#endif
Q_ASSERT(cl);

jobject obj;
Expand Down Expand Up @@ -439,7 +432,7 @@ jobject QtJambiAPI::convertQVariantToJavaObject(JNIEnv *env, const QVariant &qt_
jvalue val;
val.l = nullptr;
if(!converter || !converter(env, nullptr, qt_variant.constData(), &val, true)){
qWarning("Unable to convert qVariant to jobject");
qCWarning(DebugAPI::internalCategory, "Unable to convert qVariant to jobject");
}
return val.l;
}
Expand Down Expand Up @@ -1730,7 +1723,7 @@ QVariant internal_convertJavaObjectToQVariant(JNIEnv *env, jobject java_object,
val.l = java_object;
bool result = converter(env, &scope, val, ptr, jValueType::l);
if(!result){
qWarning("Cannot convert external type '%s' to '%s'",
qCWarning(DebugAPI::internalCategory, "Cannot convert external type '%s' to '%s'",
qPrintable(fullJavaName.replace("/", ".").replace("$", ".")),
qPrintable(qtName));
return QVariant(META_TYPE(QMetaType::UnknownType), nullptr);
Expand Down Expand Up @@ -2317,7 +2310,7 @@ jobject internal_convertQObjectSmartPointerToJavaObject_notype(JNIEnv *env, cons
}
env->DeleteLocalRef(nativeLink);
if (!link) {
qWarning("Qt Jambi: Couldn't created wrapper for class %s", className);
qCWarning(DebugAPI::internalCategory, "Qt Jambi: Couldn't created wrapper for class %s", className);
return nullptr;
}
}else{
Expand Down Expand Up @@ -2411,7 +2404,7 @@ jobject internal_convertQObjectSmartPointerToJavaObject_notype(JNIEnv *env, cons

link = QtJambiLink::createLinkForSmartPointerToQObject(env, object, false, false, const_cast<void*>(ptr_shared_pointer), shared_pointer_deleter, pointerGetter);
if (!link) {
qWarning("Qt Jambi: Couldn't created wrapper for class %s", className);
qCWarning(DebugAPI::internalCategory, "Qt Jambi: Couldn't created wrapper for class %s", className);
return nullptr;
}
}
Expand Down Expand Up @@ -2612,18 +2605,18 @@ jobject internal_convertQObjectToJavaObject_notype(JNIEnv *env, const QObject *c
obj = env->NewObject(clazz, constructorId, 0);
JavaException::check(env QTJAMBI_STACKTRACEINFO );
if (!obj){
qWarning("Qt Jambi: Couldn't created object of class %s", qPrintable(java_name));
qCWarning(DebugAPI::internalCategory, "Qt Jambi: Couldn't created object of class %s", qPrintable(java_name));
return nullptr;
}
}
}else{
qWarning("Qt Jambi: Couldn't find java class %s", qPrintable(java_name));
qCWarning(DebugAPI::internalCategory, "Qt Jambi: Couldn't find java class %s", qPrintable(java_name));
return nullptr;
}

link = QtJambiLink::createLinkForQObject(env, obj, qt_object, false, false);
if (!link) {
qWarning("Qt Jambi: Couldn't created wrapper for class %s", qPrintable(java_name));
qCWarning(DebugAPI::internalCategory, "Qt Jambi: Couldn't created wrapper for class %s", qPrintable(java_name));
return nullptr;
}
}
Expand Down
Loading

0 comments on commit 0fbd3fe

Please sign in to comment.