diff --git a/src/core/core-components/qcamera.h b/src/core/core-components/qcamera.h
index 4bf2553..e3d6b2e 100644
--- a/src/core/core-components/qcamera.h
+++ b/src/core/core-components/qcamera.h
@@ -163,6 +163,7 @@ Q_SIGNALS:
protected:
Q_DECLARE_PRIVATE(QCamera)
+ QT3D_CLONEABLE(QCamera)
QCamera(QCameraPrivate &dd, QNode *parent = 0);
};
diff --git a/src/core/nodes/qnode.h b/src/core/nodes/qnode.h
index c44c929..cce0cb7 100644
--- a/src/core/nodes/qnode.h
+++ b/src/core/nodes/qnode.h
@@ -41,6 +41,7 @@
#include <Qt3DCore/qt3dcore_global.h>
#include <Qt3DCore/qnodeid.h>
#include <Qt3DCore/qscenechange.h>
+#include <Qt3DCore/qabstractnodefactory.h>
#define Q_NODE_NULLPTR static_cast<Qt3D::QNode *>(Q_NULLPTR)
@@ -56,14 +57,15 @@ class QAspectEngine;
typedef QList<QNode *> QNodeList;
typedef QSharedPointer<QNode> QNodePtr;
+#define QT3D_QUOTE(str) #str
#define QT3D_CLONEABLE(Class) \
+ friend class QAbstractNodeFactory; \
QNode *doClone() const Q_DECL_OVERRIDE { \
- Class *clone_ = new Class; \
+ Class *clone_ = Qt3D::QAbstractNodeFactory::createNode<Class>(QT3D_QUOTE(Class)); \
clone_->copy(this); \
return clone_; \
}
-
// Each QNode subclass should call QNode::cleanup in it dtor
// QNode::cleanup checks that a flags wasn't set to true,
// sets it to true and sends a clone to the backend
INFO - New header: src/core/nodes/qabstractnodefactory.h
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QABSTRACTNODEFACTORY_H
#define QABSTRACTNODEFACTORY_H
#include <Qt3DCore/qt3dcore_global.h>
#include <Qt3DCore/qnode.h>
QT_BEGIN_NAMESPACE
namespace Qt3D {
class QT3DCORESHARED_EXPORT QAbstractNodeFactory
{
public:
virtual ~QAbstractNodeFactory();
virtual QNode *createNode(const char *type) = 0;
static void registerNodeFactory(QAbstractNodeFactory *factory);
static QList<QAbstractNodeFactory *> nodeFactories();
template<class T> static T *createNode(const char *type)
{
Q_FOREACH (QAbstractNodeFactory *f, QAbstractNodeFactory::nodeFactories()) {
QNode *n = f->createNode(type);
if (n)
return qobject_cast<T *>(n);
}
return new T;
}
};
} // namespace Qt3D
QT_END_NAMESPACE
#endif // QABSTRACTNODEFACTORY_H
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development