Skip to content
GitLab
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
972ef2b2
Commit
972ef2b2
authored
Jan 19, 2010
by
Erik Verbruggen
Browse files
Changed the applyChanges() method to return whether or not rewriting succeeded.
parent
7dadea26
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmldesigner/core/model/modeltotextmerger.cpp
View file @
972ef2b2
...
...
@@ -191,7 +191,7 @@ RewriterView *ModelToTextMerger::view()
return
m_rewriterView
;
}
void
ModelToTextMerger
::
applyChanges
()
bool
ModelToTextMerger
::
applyChanges
()
{
if
(
m_rewriteActions
.
isEmpty
())
return
;
...
...
@@ -223,6 +223,8 @@ void ModelToTextMerger::applyChanges()
textModifier
->
deactivateChangeSignals
();
textModifier
->
startGroup
();
bool
success
=
true
;
for
(
int
i
=
0
;
i
<
m_rewriteActions
.
size
();
++
i
)
{
if
(
i
!=
0
)
{
textModifier
->
flushGroup
();
...
...
@@ -235,15 +237,15 @@ void ModelToTextMerger::applyChanges()
}
ModelNodePositionStorage
*
positionStore
=
m_rewriterView
->
positionStorage
();
const
bool
success
=
action
->
execute
(
refactoring
,
*
positionStore
);
success
=
action
->
execute
(
refactoring
,
*
positionStore
);
if
(
!
success
/*&& DebugRewriteActions*/
)
{
qDebug
()
<<
"*** QML source code: ***"
;
qDebug
()
<<
qPrintable
(
textModifier
->
text
());
qDebug
()
<<
"*** End of QML source code. ***"
;
}
Q_ASSERT
(
success
);
break
;
}
}
qDeleteAll
(
m_rewriteActions
);
m_rewriteActions
.
clear
();
...
...
@@ -254,10 +256,15 @@ void ModelToTextMerger::applyChanges()
textModifier
->
reactivateChangeSignals
();
}
catch
(...)
{
qDeleteAll
(
m_rewriteActions
);
m_rewriteActions
.
clear
();
textModifier
->
commitGroup
();
textModifier
->
reactivateChangeSignals
();
throw
;
}
return
success
;
}
void
ModelToTextMerger
::
reindent
(
const
QMap
<
int
,
int
>
&
/*dirtyAreas*/
)
const
...
...
src/plugins/qmldesigner/core/model/modeltotextmerger.h
View file @
972ef2b2
...
...
@@ -57,7 +57,7 @@ class ModelToTextMerger
public:
ModelToTextMerger
(
RewriterView
*
reWriterView
);
void
applyChanges
();
bool
applyChanges
();
// Note: his method might throw exceptions, as the model works this way. So to handle rewriting failures, you will also need to catch any exception coming out.
void
nodeCreated
(
const
ModelNode
&
createdNode
);
void
nodeRemoved
(
const
ModelNode
&
removedNode
,
const
NodeAbstractProperty
&
parentProperty
,
PropertyChangeFlags
propertyChange
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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