Commit 81177fab authored by Kai Koehne's avatar Kai Koehne
Browse files

QuickDesigner: Fix assert in rewriter when quickly closing files

Make sure that the transaction doesn't last across models.

Reviewed-by: Thomas Hartmann
Task-number: QTCREATORBUG-4136
parent c18a89ff
......@@ -38,7 +38,7 @@
namespace QmlDesigner {
PropertyEditorTransaction::PropertyEditorTransaction(QmlDesigner::PropertyEditor *propertyEditor) : QObject(propertyEditor), m_propertyEditor(propertyEditor)
PropertyEditorTransaction::PropertyEditorTransaction(QmlDesigner::PropertyEditor *propertyEditor) : QObject(propertyEditor), m_propertyEditor(propertyEditor), m_timerId(-1)
{
}
......@@ -49,17 +49,21 @@ void PropertyEditorTransaction::start()
if (m_rewriterTransaction.isValid())
m_rewriterTransaction.commit();
m_rewriterTransaction = m_propertyEditor->beginRewriterTransaction();
startTimer(4000);
m_timerId = startTimer(4000);
}
void PropertyEditorTransaction::end()
{
if (m_rewriterTransaction.isValid() && m_propertyEditor->model())
if (m_rewriterTransaction.isValid() && m_propertyEditor->model()) {
killTimer(m_timerId);
m_rewriterTransaction.commit();
}
}
void PropertyEditorTransaction::timerEvent(QTimerEvent *timerEvent)
{
if (timerEvent->timerId() != m_timerId)
return;
killTimer(timerEvent->timerId());
if (m_rewriterTransaction.isValid())
m_rewriterTransaction.commit();
......
......@@ -53,6 +53,7 @@ protected:
private:
QmlDesigner::PropertyEditor *m_propertyEditor;
QmlDesigner::RewriterTransaction m_rewriterTransaction;
int m_timerId;
};
} //QmlDesigner
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment