fixed copy to clipboard crash when there is nothing to copy

This commit is contained in:
Mikulas Florek 2016-09-06 15:59:34 +02:00
parent a795759ed2
commit 9f24a35c35

View file

@ -204,20 +204,23 @@ void LogUI::onGUI()
} }
} }
char* mem = (char*)m_allocator.allocate(len); if (len > 0)
mem[0] = '\0';
for (int i = 0; i < messages->size(); ++i)
{ {
const char* msg = (*messages)[i].c_str(); char* mem = (char*)m_allocator.allocate(len);
if (filter[0] == '\0' || strstr(msg, filter) != nullptr) mem[0] = '\0';
for (int i = 0; i < messages->size(); ++i)
{ {
Lumix::catString(mem, len, msg); const char* msg = (*messages)[i].c_str();
Lumix::catString(mem, len, "\n"); if (filter[0] == '\0' || strstr(msg, filter) != nullptr)
{
Lumix::catString(mem, len, msg);
Lumix::catString(mem, len, "\n");
}
} }
}
PlatformInterface::copyToClipboard(mem); PlatformInterface::copyToClipboard(mem);
m_allocator.deallocate(mem); m_allocator.deallocate(mem);
}
} }
if (ImGui::BeginChild("log_messages")) if (ImGui::BeginChild("log_messages"))