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

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
ViewLogger::ViewLogger(QObject *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).
replace(':', '-'));
QTemporaryFile *temporaryFile = new QTemporaryFile(path, this);
static QTemporaryFile *temporaryFile = new QTemporaryFile(path, this);
temporaryFile->setAutoRemove(false);
if (temporaryFile->open()) {
static bool fileOpen = temporaryFile->open();
if (fileOpen) {
qDebug() << "QmlDesigner: Log file is:" << temporaryFile->fileName();
m_output.setDevice(temporaryFile);
} else {
qDebug() << "QmlDesigner: failed to open:" << temporaryFile->fileName();
}
m_timer.start();
}
void ViewLogger::modelAttached(Model *model)
{
m_output << time() << indent("modelAttached:") << model << endl;
AbstractView::modelAttached(model);
}
......
......@@ -92,6 +92,10 @@ void ViewManager::detachViewsExceptRewriterAndComponetView()
currentModel()->detachView(&m_statesEditorView);
currentModel()->detachView(&m_propertyEditorView);
currentModel()->setNodeInstanceView(0);
static bool enableViewLogger = !qgetenv("QTC_ENABLE_QMLDESIGNER_LOGGER").isEmpty();
if (enableViewLogger)
currentModel()->detachView(&m_viewLogger);
}
void ViewManager::attachItemLibraryView()
......@@ -114,6 +118,10 @@ void ViewManager::detachComponentView()
void ViewManager::attachViewsExceptRewriterAndComponetView()
{
static bool enableViewLogger = !qgetenv("QTC_ENABLE_QMLDESIGNER_LOGGER").isEmpty();
if (enableViewLogger)
currentModel()->attachView(&m_viewLogger);
attachNodeInstanceView();
currentModel()->attachView(&m_formEditorView);
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