mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Fixed logging to clipboard on architectures where va_list are modified by vsnprintf (fixed #112)
This commit is contained in:
parent
5322224881
commit
3a20671802
13
imgui.cpp
13
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.20
|
// ImGui library v1.21 wip
|
||||||
// See ImGui::ShowTestWindow() for sample code.
|
// See ImGui::ShowTestWindow() for sample code.
|
||||||
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
|
// Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
|
||||||
// Get latest version at https://github.com/ocornut/imgui
|
// Get latest version at https://github.com/ocornut/imgui
|
||||||
@ -1180,9 +1180,18 @@ bool ImGuiTextFilter::PassFilter(const char* val) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// On some platform vsnprintf() takes va_list by reference and modifies it.
|
||||||
|
// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it.
|
||||||
|
#ifndef va_copy
|
||||||
|
#define va_copy(dest, src) (dest = src)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Helper: Text buffer for logging/accumulating text
|
// Helper: Text buffer for logging/accumulating text
|
||||||
void ImGuiTextBuffer::appendv(const char* fmt, va_list args)
|
void ImGuiTextBuffer::appendv(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
va_list args_copy;
|
||||||
|
va_copy(args_copy, args);
|
||||||
|
|
||||||
int len = vsnprintf(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
|
int len = vsnprintf(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return;
|
return;
|
||||||
@ -1191,7 +1200,7 @@ void ImGuiTextBuffer::appendv(const char* fmt, va_list args)
|
|||||||
Buf.reserve(Buf.capacity() * 2);
|
Buf.reserve(Buf.capacity() * 2);
|
||||||
|
|
||||||
Buf.resize(write_off + (size_t)len);
|
Buf.resize(write_off + (size_t)len);
|
||||||
ImFormatStringV(&Buf[write_off] - 1, (size_t)len+1, fmt, args);
|
ImFormatStringV(&Buf[write_off] - 1, (size_t)len+1, fmt, args_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiTextBuffer::append(const char* fmt, ...)
|
void ImGuiTextBuffer::append(const char* fmt, ...)
|
||||||
|
2
imgui.h
2
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.20
|
// ImGui library v1.21 wip
|
||||||
// See .cpp file for commentary.
|
// See .cpp file for commentary.
|
||||||
// See ImGui::ShowTestWindow() for sample code.
|
// See ImGui::ShowTestWindow() for sample code.
|
||||||
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
||||||
|
Loading…
Reference in New Issue
Block a user