Crash when copying and pasting in several editors (sprite, map editor) #558

This commit is contained in:
BADIM-PC\Vadim 2018-03-01 18:59:41 +03:00
parent 81fbd92f60
commit 8484a86819
8 changed files with 22 additions and 4 deletions

2
.gitignore vendored
View File

@ -122,3 +122,5 @@ build/uwp/sdl-gpu-static/Release Pro/
build/uwp/sdl-gpu-static/ARM/
build/uwp/sdl-gpu-static/x64/
build/uwp/tic/packages/
build/windows/studio/x64/
build/windows/sdl-gpu/x64/

View File

@ -590,7 +590,7 @@ static void copyFromClipboard(Code* code)
parseSyntaxColor(code);
}
free(clipboard);
getSystem()->freeClipboardText(clipboard);
}
}
}

View File

@ -1004,7 +1004,7 @@ static void copyFromClipboard(Map* map)
else free(data);
}
free(clipboard);
getSystem()->freeClipboardText(clipboard);
}
}
}

View File

@ -651,7 +651,7 @@ static void copyFromClipboard(Music* music)
free(data);
}
free(clipboard);
getSystem()->freeClipboardText(clipboard);
}
}
}

View File

@ -417,7 +417,7 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces)
if(valid) str2buf(clipboard, strlen(clipboard), data, flip);
free(clipboard);
getSystem()->freeClipboardText(clipboard);
return valid;
}

View File

@ -876,6 +876,11 @@ static char* getClipboardText()
return SDL_GetClipboardText();
}
static void freeClipboardText(const char* text)
{
SDL_free((void*)text);
}
static u64 getPerformanceCounter()
{
return SDL_GetPerformanceCounter();
@ -1057,6 +1062,8 @@ static System systemInterface =
.setClipboardText = setClipboardText,
.hasClipboardText = hasClipboardText,
.getClipboardText = getClipboardText,
.freeClipboardText = freeClipboardText,
.getPerformanceCounter = getPerformanceCounter,
.getPerformanceFrequency = getPerformanceFrequency,

View File

@ -8,6 +8,8 @@ typedef struct
void (*setClipboardText)(const char* text);
bool (*hasClipboardText)();
char* (*getClipboardText)();
void (*freeClipboardText)(const char* text);
u64 (*getPerformanceCounter)();
u64 (*getPerformanceFrequency)();

View File

@ -517,6 +517,11 @@ static char* getClipboardText()
return SDL_GetClipboardText();
}
static void freeClipboardText(const char* text)
{
SDL_free((void*)text);
}
static u64 getPerformanceCounter()
{
return SDL_GetPerformanceCounter();
@ -599,6 +604,8 @@ static System systemInterface =
.setClipboardText = setClipboardText,
.hasClipboardText = hasClipboardText,
.getClipboardText = getClipboardText,
.freeClipboardText = freeClipboardText,
.getPerformanceCounter = getPerformanceCounter,
.getPerformanceFrequency = getPerformanceFrequency,