Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
58730837
Commit
58730837
authored
Sep 24, 2010
by
Thomas Hartmann
Browse files
QmlDesigner.dragAndDrop: this avoids asserts for unknown types
This avoids asserts and catches exceptions
parent
213b789d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/components/formeditor/dragtool.cpp
View file @
58730837
...
...
@@ -35,12 +35,14 @@
#include "itemutilfunctions.h"
#include <customdraganddrop.h>
#include <metainfo.h>
#include <rewritingexception.h>
#include "resizehandleitem.h"
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
#include <QtDebug>
#include <QMessageBox>
namespace
QmlDesigner
{
...
...
@@ -143,7 +145,6 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
m_dragNode
=
view
()
->
createQmlItemNode
(
itemLibraryEntry
,
pos
,
parentNode
);
Q_ASSERT
(
m_dragNode
.
modelNode
().
isValid
());
Q_ASSERT
(
m_dragNode
.
isValid
());
QList
<
QmlItemNode
>
nodeList
;
nodeList
.
append
(
m_dragNode
);
...
...
@@ -205,7 +206,11 @@ void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
event
->
accept
();
end
(
event
->
scenePos
());
//Q_ASSERT(m_token.isValid());
m_rewriterTransaction
.
commit
();
try
{
m_rewriterTransaction
.
commit
();
}
catch
(
RewritingException
&
e
)
{
QMessageBox
::
warning
(
0
,
"Error"
,
e
.
description
());
}
m_dragNode
=
ModelNode
();
view
()
->
changeToSelectionTool
();
}
...
...
@@ -230,7 +235,13 @@ void DragTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
if
(
m_dragNode
.
isValid
())
m_dragNode
.
destroy
();
end
(
event
->
scenePos
());
m_rewriterTransaction
.
commit
();
try
{
m_rewriterTransaction
.
commit
();
}
catch
(
RewritingException
&
e
)
{
QMessageBox
::
warning
(
0
,
"Error"
,
e
.
description
());
}
QmlDesignerItemLibraryDragAndDrop
::
CustomDragAndDrop
::
show
();
QList
<
QmlItemNode
>
nodeList
;
view
()
->
setSelectedQmlItemNodes
(
nodeList
);
...
...
@@ -267,6 +278,8 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
move
(
event
->
scenePos
());
}
else
{
//create new node if container
if
(
m_dragNode
.
modelNode
().
isValid
())
return
;
FormEditorItem
*
parentItem
=
calculateContainer
(
event
->
scenePos
());
if
(
!
parentItem
)
...
...
@@ -284,7 +297,8 @@ void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
QString
imageName
=
QString
::
fromLatin1
((
event
->
mimeData
()
->
data
(
"application/vnd.bauhaus.libraryresource"
)));
createQmlItemNodeFromImage
(
imageName
,
parentNode
,
event
->
scenePos
());
}
else
Q_ASSERT
(
false
);
beginWithPoint
(
event
->
scenePos
());
if
(
m_dragNode
.
isValid
())
beginWithPoint
(
event
->
scenePos
());
}
}
if
(
event
->
mimeData
()
->
hasFormat
(
"application/vnd.bauhaus.libraryresource"
))
{
...
...
src/plugins/qmldesigner/designercore/model/qmlmodelview.cpp
View file @
58730837
...
...
@@ -199,7 +199,8 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
parentNode
.
nodeAbstractProperty
(
parentNode
.
defaultProperty
()).
reparentHere
(
newNode
);
}
Q_ASSERT
(
newNode
.
isValid
());
if
(
!
newNode
.
isValid
())
return
newNode
;
QString
id
;
int
i
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment