Commit 8d4618e4 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Start logger only if designer is started



Task-number: QTCREATORBUG-8618

Change-Id: I73c2256893029a4a1a0725c14df432a87ee7e827
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
parent 497b7fa4
...@@ -65,23 +65,24 @@ QString ViewLogger::time() const ...@@ -65,23 +65,24 @@ QString ViewLogger::time() const
ViewLogger::ViewLogger(QObject *parent) ViewLogger::ViewLogger(QObject *parent)
: AbstractView(parent) : AbstractView(parent)
{ {
const QString path = QDir::tempPath() + QString("/qmldesigner-logger-%1-XXXXXX.txt"). m_timer.start();
}
void ViewLogger::modelAttached(Model *model)
{
static const QString path = QDir::tempPath() + QString("/qmldesigner-logger-%1-XXXXXX.txt").
arg(QDateTime::currentDateTime().toString(Qt::ISODate). arg(QDateTime::currentDateTime().toString(Qt::ISODate).
replace(':', '-')); replace(':', '-'));
QTemporaryFile *temporaryFile = new QTemporaryFile(path, this); static QTemporaryFile *temporaryFile = new QTemporaryFile(path, this);
temporaryFile->setAutoRemove(false); temporaryFile->setAutoRemove(false);
if (temporaryFile->open()) { static bool fileOpen = temporaryFile->open();
if (fileOpen) {
qDebug() << "QmlDesigner: Log file is:" << temporaryFile->fileName(); qDebug() << "QmlDesigner: Log file is:" << temporaryFile->fileName();
m_output.setDevice(temporaryFile); m_output.setDevice(temporaryFile);
} else { } else {
qDebug() << "QmlDesigner: failed to open:" << temporaryFile->fileName(); qDebug() << "QmlDesigner: failed to open:" << temporaryFile->fileName();
} }
m_timer.start();
}
void ViewLogger::modelAttached(Model *model)
{
m_output << time() << indent("modelAttached:") << model << endl; m_output << time() << indent("modelAttached:") << model << endl;
AbstractView::modelAttached(model); AbstractView::modelAttached(model);
} }
......
...@@ -92,6 +92,10 @@ void ViewManager::detachViewsExceptRewriterAndComponetView() ...@@ -92,6 +92,10 @@ void ViewManager::detachViewsExceptRewriterAndComponetView()
currentModel()->detachView(&m_statesEditorView); currentModel()->detachView(&m_statesEditorView);
currentModel()->detachView(&m_propertyEditorView); currentModel()->detachView(&m_propertyEditorView);
currentModel()->setNodeInstanceView(0); currentModel()->setNodeInstanceView(0);
static bool enableViewLogger = !qgetenv("QTC_ENABLE_QMLDESIGNER_LOGGER").isEmpty();
if (enableViewLogger)
currentModel()->detachView(&m_viewLogger);
} }
void ViewManager::attachItemLibraryView() void ViewManager::attachItemLibraryView()
...@@ -114,6 +118,10 @@ void ViewManager::detachComponentView() ...@@ -114,6 +118,10 @@ void ViewManager::detachComponentView()
void ViewManager::attachViewsExceptRewriterAndComponetView() void ViewManager::attachViewsExceptRewriterAndComponetView()
{ {
static bool enableViewLogger = !qgetenv("QTC_ENABLE_QMLDESIGNER_LOGGER").isEmpty();
if (enableViewLogger)
currentModel()->attachView(&m_viewLogger);
attachNodeInstanceView(); attachNodeInstanceView();
currentModel()->attachView(&m_formEditorView); currentModel()->attachView(&m_formEditorView);
currentModel()->attachView(&m_navigatorView); currentModel()->attachView(&m_navigatorView);
......
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