Skip to content

Commit

Permalink
Traktor: Highlight status bar if there is an warning or error in the …
Browse files Browse the repository at this point in the history
…output log.
  • Loading branch information
apistol78 committed Jun 3, 2024
1 parent b8d8e62 commit a778680
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
33 changes: 21 additions & 12 deletions code/Editor/App/EditorForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,19 +1913,23 @@ void EditorForm::buildWaitUntilFinished()
if (!m_threadBuild)
return;

if (ThreadManager::getInstance().getCurrentThread() == ThreadManager::getInstance().getMainThread())
const bool running = m_threadBuild->wait(0);
if (!running)
{
// Show a dialog if processing seems to take more than N second(s).
ui::BackgroundWorkerDialog dialog;
dialog.create(this, i18n::Text(L"EDITOR_WAIT_BUILDING_TITLE"), i18n::Text(L"EDITOR_WAIT_BUILDING_MESSAGE"), false);
dialog.execute(m_threadBuild, new BuildStatus(m_buildStep, m_buildStepMessage, m_buildStepMessageLock));
dialog.destroy();
}
else
{
// Since we cannot show a dialog from other than main thread we just wait for the
// build thread to finish.
m_threadBuild->wait();
if (ThreadManager::getInstance().getCurrentThread() == ThreadManager::getInstance().getMainThread())
{
// Show a dialog if processing seems to take more than N second(s).
ui::BackgroundWorkerDialog dialog;
dialog.create(this, i18n::Text(L"EDITOR_WAIT_BUILDING_TITLE"), i18n::Text(L"EDITOR_WAIT_BUILDING_MESSAGE"), false);
dialog.execute(m_threadBuild, new BuildStatus(m_buildStep, m_buildStepMessage, m_buildStepMessageLock));
dialog.destroy();
}
else
{
// Since we cannot show a dialog from other than main thread we just wait for the
// build thread to finish.
m_threadBuild->wait();
}
}

// As build thread is no longer in use we can safely release it's resources.
Expand Down Expand Up @@ -3064,6 +3068,11 @@ void EditorForm::eventTimer(ui::TimerEvent* /*event*/)
else
m_statusBar->setText(2, L"");

if (m_logView->haveWarnings() || m_logView->haveErrors())
m_statusBar->setAlert(true);
else
m_statusBar->setAlert(false);

if (m_pipelineCache)
{
StringOutputStream ss;
Expand Down
9 changes: 7 additions & 2 deletions code/Editor/LogView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ bool LogView::create(ui::Widget* parent)
return true;
}

void LogView::destroy()
bool LogView::haveWarnings() const
{
ui::Container::destroy();
return m_log->countLog(ui::LogList::LvWarning) != 0;
}

bool LogView::haveErrors() const
{
return m_log->countLog(ui::LogList::LvError) != 0;
}

void LogView::eventToolClick(ui::ToolBarButtonClickEvent* event)
Expand Down
4 changes: 3 additions & 1 deletion code/Editor/LogView.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class T_DLLCLASS LogView

bool create(ui::Widget* parent);

virtual void destroy() override final;
bool haveWarnings() const;

bool haveErrors() const;

ILogTarget* getLogTarget() const { return m_logTarget; }

Expand Down
21 changes: 19 additions & 2 deletions code/Ui/LogList/LogList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ void LogList::add(uint32_t threadId, LogLevel level, const std::wstring& text)
size_t i = 0;
for (;;)
{
size_t j = e.text.find(L'{', i);
const size_t j = e.text.find(L'{', i);
if (j == std::wstring::npos)
break;

Guid id(e.text.substr(j));
const Guid id(e.text.substr(j));
if (id.isValid())
{
e.symbolId = id;
Expand Down Expand Up @@ -178,6 +178,23 @@ bool LogList::copyLog(uint8_t filter)
return Application::getInstance()->getClipboard()->setText(ss.str());
}

uint32_t LogList::countLog(uint8_t level) const
{
switch (level)
{
case LvInfo:
return m_logCount[0];
case LvWarning:
return m_logCount[1];
case LvError:
return m_logCount[2];
case LvDebug:
return m_logCount[3];
default:
return 0;
}
}

void LogList::forEachLine(const std::function< void(int32_t line, const std::wstring& text) >& fn) const
{
for (int32_t line = 0; line < (int32_t)m_logFull.size(); ++line)
Expand Down
2 changes: 2 additions & 0 deletions code/Ui/LogList/LogList.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class T_DLLCLASS LogList : public Widget

bool copyLog(uint8_t filter = ~0);

uint32_t countLog(uint8_t level) const;

void forEachLine(const std::function< void(int32_t line, const std::wstring& text) >& fn) const;

void forEachFilteredLine(const std::function< void(int32_t line, const std::wstring& text) >& fn) const;
Expand Down

0 comments on commit a778680

Please sign in to comment.