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