Changes for PR #31

This commit is contained in:
Moritz Maxeiner 2015-12-24 12:04:31 +01:00
parent 02efef24ef
commit cfb05fae25
1 changed files with 2 additions and 2 deletions

View File

@ -109,12 +109,12 @@ void dos_qqmlapplicationengine_context(void* vptr, void** context)
void dos_qqmlapplicationengine_rootObjects(void* vptr, void*** array, int* array_length) void dos_qqmlapplicationengine_rootObjects(void* vptr, void*** array, int* array_length)
{ {
QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr); QQmlApplicationEngine* engine = reinterpret_cast<QQmlApplicationEngine*>(vptr);
auto list = engine->rootObjects(); QList<QObject*> list = engine->rootObjects();
// Note: On fringe architectures where `8 < CHAR_BIT` this may not allocate enough memory, // 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 // as sizeof returns the number of chars required, while calloc/malloc expects
// the number of octets required. // the number of octets required.
QObject** objects = reinterpret_cast<QObject**>(calloc(list.length(), sizeof(QObject*))); QObject** objects = reinterpret_cast<QObject**>(calloc(list.length(), sizeof(QObject*)));
if (objects == NULL) return; if (objects == nullptr) return;
for (int i = 0; i < list.length(); i += 1) objects[i] = list.at(i); for (int i = 0; i < list.length(); i += 1) objects[i] = list.at(i);
*array = reinterpret_cast<void**>(objects); *array = reinterpret_cast<void**>(objects);
*array_length = list.length(); *array_length = list.length();