diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-06-20 09:55:58 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-06-20 10:32:13 +0000 |
commit | c5f8f9c467fc1d961bcfc62f723f7c6f3e3df95c (patch) | |
tree | 6f825110e53fcd15d13c2ed5c05a8b10a019b535 /src/runtime/q3dsuippresentation_p.h | |
parent | 365692e267086fc5f221f1c0e76fdbd086e244ad (diff) |
newObject: reject duplicate ids by returning null
Preventing the console or any other user of the API to create objects
with the same id is essential. (ids are unique, names are not)
This has been in place already in registerObject but newObject returned
a valid object even when registerObject failed. This is now corrected.
Change-Id: I77fed32c4f208774e33c945e085c5c5b1b6e34d8
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/runtime/q3dsuippresentation_p.h')
-rw-r--r-- | src/runtime/q3dsuippresentation_p.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/runtime/q3dsuippresentation_p.h b/src/runtime/q3dsuippresentation_p.h index 42d4f33..73f20cf 100644 --- a/src/runtime/q3dsuippresentation_p.h +++ b/src/runtime/q3dsuippresentation_p.h @@ -1987,7 +1987,7 @@ public: void setScene(Q3DSScene *p); void setMasterSlide(Q3DSSlide *p); - void registerObject(const QByteArray &id, Q3DSGraphObject *p); // covers both the scene and slide graphs + bool registerObject(const QByteArray &id, Q3DSGraphObject *p); // covers both the scene and slide graphs void unregisterObject(const QByteArray &id); template <typename T = Q3DSGraphObject> @@ -2041,8 +2041,7 @@ public: template<typename T> T *newObject(const QByteArray &id) { T *obj = new T; - registerObject(id, obj); // also sets obj->id - return obj; + return registerObject(id, obj) ? obj : nullptr; // also sets obj->id } void unlinkObject(Q3DSGraphObject *obj) |