minor fixes

docking
Sepehr Taghdisian 11 years ago
parent ef628a0a9d
commit 47fd8431c1

@ -162,12 +162,12 @@
#include <stdint.h> // intptr_t #include <stdint.h> // intptr_t
#include <stdio.h> // vsnprintf #include <stdio.h> // vsnprintf
#include <string.h> // memset #include <string.h> // memset
#include <new> // new (ptr)
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#endif #endif
#include <new>
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Forward Declarations // Forward Declarations
@ -198,8 +198,8 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
}; // namespace ImGui }; // namespace ImGui
static char* StrDup(const char *str); static char* ImStrDup(const char *str);
static void StrDup_Free(char *str); static void ImStrDup_Free(char *str);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Platform dependant default implementations // Platform dependant default implementations
@ -596,7 +596,7 @@ struct ImGuiIniData
bool Collapsed; bool Collapsed;
ImGuiIniData() { memset(this, 0, sizeof(*this)); } ImGuiIniData() { memset(this, 0, sizeof(*this)); }
~ImGuiIniData() { if (Name) { StrDup_Free(Name); Name = NULL; } } ~ImGuiIniData() { if (Name) { ImStrDup_Free(Name); Name = NULL; } }
}; };
struct ImGuiState struct ImGuiState
@ -918,7 +918,7 @@ void ImGuiTextBuffer::append(const char* fmt, ...)
ImGuiWindow::ImGuiWindow(const char* name, ImVec2 default_pos, ImVec2 default_size) ImGuiWindow::ImGuiWindow(const char* name, ImVec2 default_pos, ImVec2 default_size)
{ {
Name = StrDup(name); Name = ImStrDup(name);
ID = GetID(name); ID = GetID(name);
IDStack.push_back(ID); IDStack.push_back(ID);
@ -953,7 +953,7 @@ ImGuiWindow::~ImGuiWindow()
DrawList->~ImDrawList(); DrawList->~ImDrawList();
GImGui.IO.FreeFn(DrawList); GImGui.IO.FreeFn(DrawList);
DrawList = NULL; DrawList = NULL;
StrDup_Free(Name); ImStrDup_Free(Name);
Name = NULL; Name = NULL;
} }
@ -1036,7 +1036,7 @@ static ImGuiIniData* FindWindowSettings(const char* name)
void *buff = GImGui.IO.MallocFn(sizeof(ImGuiIniData)); void *buff = GImGui.IO.MallocFn(sizeof(ImGuiIniData));
ImGuiIniData* ini = new(buff) ImGuiIniData(); ImGuiIniData* ini = new(buff) ImGuiIniData();
ini->Name = StrDup(name); ini->Name = ImStrDup(name);
ini->Collapsed = false; ini->Collapsed = false;
ini->Pos = ImVec2(FLT_MAX,FLT_MAX); ini->Pos = ImVec2(FLT_MAX,FLT_MAX);
ini->Size = ImVec2(0,0); ini->Size = ImVec2(0,0);
@ -5318,7 +5318,7 @@ static const char* GetClipboardTextFn_DefaultImpl()
if (buf_handle == NULL) if (buf_handle == NULL)
return NULL; return NULL;
if (char* buf_global = (char*)GlobalLock(buf_handle)) if (char* buf_global = (char*)GlobalLock(buf_handle))
buf_local = StrDup(buf_global); buf_local = ImStrDup(buf_global);
GlobalUnlock(buf_handle); GlobalUnlock(buf_handle);
CloseClipboard(); CloseClipboard();
return buf_local; return buf_local;
@ -5855,7 +5855,7 @@ void ShowTestWindow(bool* open)
}; // namespace ImGui }; // namespace ImGui
static char* StrDup(const char *str) static char* ImStrDup(const char *str)
{ {
char *buff = (char*)GImGui.IO.MallocFn(strlen(str) + 1); char *buff = (char*)GImGui.IO.MallocFn(strlen(str) + 1);
IM_ASSERT(buff); IM_ASSERT(buff);
@ -5863,7 +5863,7 @@ static char* StrDup(const char *str)
return buff; return buff;
} }
static void StrDup_Free(char *str) static void ImStrDup_Free(char *str)
{ {
IM_ASSERT(str); IM_ASSERT(str);
GImGui.IO.FreeFn(str); GImGui.IO.FreeFn(str);

@ -25,6 +25,11 @@ struct ImGuiWindow;
#define IM_ASSERT(_EXPR) assert(_EXPR) #define IM_ASSERT(_EXPR) assert(_EXPR)
#endif #endif
#ifndef IM_MALLOC
#define IM_MALLOC malloc
#endif
typedef unsigned int ImU32; typedef unsigned int ImU32;
typedef ImU32 ImGuiID; typedef ImU32 ImGuiID;
typedef int ImGuiCol; // enum ImGuiCol_ typedef int ImGuiCol; // enum ImGuiCol_

Loading…
Cancel
Save