diff --git a/lib/include/DOtherSide/DOtherSide.h b/lib/include/DOtherSide/DOtherSide.h index 0e19948..c97d197 100644 --- a/lib/include/DOtherSide/DOtherSide.h +++ b/lib/include/DOtherSide/DOtherSide.h @@ -55,6 +55,9 @@ DOS_API void dos_qqmlcontext_setcontextproperty(void* vptr, const char* name, vo // CharArray DOS_API void dos_chararray_delete(char* ptr); +// QObjectPtrArray +DOS_API void dos_qobjectptr_array_delete(void** ptr); + // QVariant DOS_API void dos_qvariant_create(void** vptr); DOS_API void dos_qvariant_create_int(void** vptr, int value); diff --git a/lib/src/DOtherSide.cpp b/lib/src/DOtherSide.cpp index e5c546e..7c8bcb0 100644 --- a/lib/src/DOtherSide.cpp +++ b/lib/src/DOtherSide.cpp @@ -110,10 +110,7 @@ void dos_qqmlapplicationengine_rootObjects(void* vptr, void*** array, int* array { QQmlApplicationEngine* engine = reinterpret_cast(vptr); QList list = engine->rootObjects(); - // Note: On fringe architectures where `8 < CHAR_BIT` this may not allocate enough memory, - // as sizeof returns the number of chars required, while calloc/malloc expects - // the number of octets required. - QObject** objects = reinterpret_cast(calloc(list.length(), sizeof(QObject*))); + auto objects = new QObject*[list.size()]; if (objects == nullptr) return; for (int i = 0; i < list.length(); i += 1) objects[i] = list.at(i); *array = reinterpret_cast(objects); @@ -180,6 +177,11 @@ void dos_chararray_delete(char* ptr) if (ptr) delete[] ptr; } +void dos_qobjectptr_array_delete(void** ptr) +{ + if (ptr) delete[] ptr; +} + void dos_qqmlcontext_baseUrl(void* vptr, char** result) { QQmlContext* context = reinterpret_cast(vptr);