diff --git a/src/corelib/kernel/qjnitypes.h b/src/corelib/kernel/qjnitypes.h index bedf368e30..dfde8c7244 100644 --- a/src/corelib/kernel/qjnitypes.h +++ b/src/corelib/kernel/qjnitypes.h @@ -28,10 +28,10 @@ struct Object : QJniObject Q_IMPLICIT Object(QJniObject &&object) : QJniObject(std::move(object)) {} // Compiler-generated copy/move semantics based on QJniObject's shared d-pointer are fine! - Object(const Object &other) = default; - Object(Object &&other) = default; - Object &operator=(const Object &other) = default; - Object &operator=(Object &&other) = default; + Object(const Object &other) = default; + Object(Object &&other) = default; + Object &operator=(const Object &other) = default; + Object &operator=(Object &&other) = default; // avoid ambiguities with deleted const char * constructor Q_IMPLICIT Object(std::nullptr_t) : QJniObject() {} @@ -41,18 +41,13 @@ struct Object : QJniObject , ValidSignatureTypes = true > explicit Object(Args &&...args) - : QJniObject(Qt::Initialization::Uninitialized) - { - *this = Object{QJniObject::construct(std::forward(args)...)}; - } + : QJniObject(QtJniTypes::Traits::className(), std::forward(args)...) + {} // named constructors avoid ambiguities - static Object fromJObject(jobject object) { return Object(object); } + static Object fromJObject(jobject object) { return Object(object); } template - static Object construct(Args &&...args) - { - return Object{QJniObject::construct(std::forward(args)...)}; - } + static Object construct(Args &&...args) { return Object{std::forward(args)...}; } // public API forwarding to QJniObject, with the implicit Class template parameter template