QmlDesigner: create DesignerSupport on stack

- it has the same life cycle like the Qt5NodeInstanceServer
 - we don't need to create and delete it (with maybe memory leaks)
 - this fixes a crash while the puppet is closed after an item deletion

Change-Id: Iecd6515eb41324b95e99e151d77ee74895230182
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Tim Jenssen
2014-10-16 13:56:47 +02:00
parent 26bf2caa59
commit 49c39eb029
2 changed files with 6 additions and 12 deletions

View File

@@ -42,8 +42,7 @@
namespace QmlDesigner { namespace QmlDesigner {
Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient)
: NodeInstanceServer(nodeInstanceClient), : NodeInstanceServer(nodeInstanceClient)
m_designerSupport(new DesignerSupport)
{ {
DesignerSupport::activateDesignerMode(); DesignerSupport::activateDesignerMode();
} }
@@ -51,8 +50,6 @@ Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeIn
Qt5NodeInstanceServer::~Qt5NodeInstanceServer() Qt5NodeInstanceServer::~Qt5NodeInstanceServer()
{ {
delete quickView(); delete quickView();
delete m_designerSupport;
m_designerSupport = 0;
} }
QQuickView *Qt5NodeInstanceServer::quickView() const QQuickView *Qt5NodeInstanceServer::quickView() const
@@ -128,21 +125,18 @@ void Qt5NodeInstanceServer::refreshBindings()
DesignerSupport::refreshExpressions(context()); DesignerSupport::refreshExpressions(context());
} }
DesignerSupport *Qt5NodeInstanceServer::designerSupport() const DesignerSupport *Qt5NodeInstanceServer::designerSupport()
{ {
return m_designerSupport; return &m_designerSupport;
} }
void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command) void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command)
{ {
m_designerSupport = new DesignerSupport;
NodeInstanceServer::createScene(command); NodeInstanceServer::createScene(command);
} }
void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command) void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command)
{ {
delete m_designerSupport;
m_designerSupport = 0;
NodeInstanceServer::clearScene(command); NodeInstanceServer::clearScene(command);
} }

View File

@@ -34,10 +34,10 @@
#include <QtGlobal> #include <QtGlobal>
#include "nodeinstanceserver.h" #include "nodeinstanceserver.h"
#include "designersupport.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QQuickItem; class QQuickItem;
class DesignerSupport;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace QmlDesigner { namespace QmlDesigner {
@@ -54,7 +54,7 @@ public:
QQmlEngine *engine() const Q_DECL_OVERRIDE; QQmlEngine *engine() const Q_DECL_OVERRIDE;
void refreshBindings() Q_DECL_OVERRIDE; void refreshBindings() Q_DECL_OVERRIDE;
DesignerSupport *designerSupport() const; DesignerSupport *designerSupport();
void createScene(const CreateSceneCommand &command) Q_DECL_OVERRIDE; void createScene(const CreateSceneCommand &command) Q_DECL_OVERRIDE;
void clearScene(const ClearSceneCommand &command) Q_DECL_OVERRIDE; void clearScene(const ClearSceneCommand &command) Q_DECL_OVERRIDE;
@@ -69,7 +69,7 @@ protected:
private: private:
QPointer<QQuickView> m_quickView; QPointer<QQuickView> m_quickView;
DesignerSupport *m_designerSupport; DesignerSupport m_designerSupport;
}; };
} // QmlDesigner } // QmlDesigner