Crash when copying and pasting in several editors (sprite, map editor) #558
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -122,3 +122,5 @@ build/uwp/sdl-gpu-static/Release Pro/ | |||||||
| build/uwp/sdl-gpu-static/ARM/ | build/uwp/sdl-gpu-static/ARM/ | ||||||
| build/uwp/sdl-gpu-static/x64/ | build/uwp/sdl-gpu-static/x64/ | ||||||
| build/uwp/tic/packages/ | build/uwp/tic/packages/ | ||||||
|  | build/windows/studio/x64/ | ||||||
|  | build/windows/sdl-gpu/x64/ | ||||||
|   | |||||||
| @@ -590,7 +590,7 @@ static void copyFromClipboard(Code* code) | |||||||
| 				parseSyntaxColor(code); | 				parseSyntaxColor(code); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			free(clipboard); | 			getSystem()->freeClipboardText(clipboard); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1004,7 +1004,7 @@ static void copyFromClipboard(Map* map) | |||||||
| 				else free(data); | 				else free(data); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			free(clipboard); | 			getSystem()->freeClipboardText(clipboard); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -651,7 +651,7 @@ static void copyFromClipboard(Music* music) | |||||||
| 				free(data); | 				free(data); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			free(clipboard); | 			getSystem()->freeClipboardText(clipboard); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -417,7 +417,7 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces) | |||||||
|  |  | ||||||
| 				if(valid) str2buf(clipboard, strlen(clipboard), data, flip); | 				if(valid) str2buf(clipboard, strlen(clipboard), data, flip); | ||||||
|  |  | ||||||
| 				free(clipboard); | 				getSystem()->freeClipboardText(clipboard); | ||||||
|  |  | ||||||
| 				return valid; | 				return valid; | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -876,6 +876,11 @@ static char* getClipboardText() | |||||||
| 	return SDL_GetClipboardText(); | 	return SDL_GetClipboardText(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void freeClipboardText(const char* text) | ||||||
|  | { | ||||||
|  | 	SDL_free((void*)text); | ||||||
|  | } | ||||||
|  |  | ||||||
| static u64 getPerformanceCounter() | static u64 getPerformanceCounter() | ||||||
| { | { | ||||||
| 	return SDL_GetPerformanceCounter(); | 	return SDL_GetPerformanceCounter(); | ||||||
| @@ -1057,6 +1062,8 @@ static System systemInterface = | |||||||
| 	.setClipboardText = setClipboardText, | 	.setClipboardText = setClipboardText, | ||||||
| 	.hasClipboardText = hasClipboardText, | 	.hasClipboardText = hasClipboardText, | ||||||
| 	.getClipboardText = getClipboardText, | 	.getClipboardText = getClipboardText, | ||||||
|  | 	.freeClipboardText = freeClipboardText, | ||||||
|  |  | ||||||
| 	.getPerformanceCounter = getPerformanceCounter, | 	.getPerformanceCounter = getPerformanceCounter, | ||||||
| 	.getPerformanceFrequency = getPerformanceFrequency, | 	.getPerformanceFrequency = getPerformanceFrequency, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,6 +8,8 @@ typedef struct | |||||||
| 	void	(*setClipboardText)(const char* text); | 	void	(*setClipboardText)(const char* text); | ||||||
| 	bool	(*hasClipboardText)(); | 	bool	(*hasClipboardText)(); | ||||||
| 	char* 	(*getClipboardText)(); | 	char* 	(*getClipboardText)(); | ||||||
|  | 	void 	(*freeClipboardText)(const char* text); | ||||||
|  |  | ||||||
| 	u64 	(*getPerformanceCounter)(); | 	u64 	(*getPerformanceCounter)(); | ||||||
| 	u64 	(*getPerformanceFrequency)(); | 	u64 	(*getPerformanceFrequency)(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -517,6 +517,11 @@ static char* getClipboardText() | |||||||
| 	return SDL_GetClipboardText(); | 	return SDL_GetClipboardText(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void freeClipboardText(const char* text) | ||||||
|  | { | ||||||
|  | 	SDL_free((void*)text); | ||||||
|  | } | ||||||
|  |  | ||||||
| static u64 getPerformanceCounter() | static u64 getPerformanceCounter() | ||||||
| { | { | ||||||
| 	return SDL_GetPerformanceCounter(); | 	return SDL_GetPerformanceCounter(); | ||||||
| @@ -599,6 +604,8 @@ static System systemInterface = | |||||||
| 	.setClipboardText = setClipboardText, | 	.setClipboardText = setClipboardText, | ||||||
| 	.hasClipboardText = hasClipboardText, | 	.hasClipboardText = hasClipboardText, | ||||||
| 	.getClipboardText = getClipboardText, | 	.getClipboardText = getClipboardText, | ||||||
|  | 	.freeClipboardText = freeClipboardText, | ||||||
|  | 	 | ||||||
| 	.getPerformanceCounter = getPerformanceCounter, | 	.getPerformanceCounter = getPerformanceCounter, | ||||||
| 	.getPerformanceFrequency = getPerformanceFrequency, | 	.getPerformanceFrequency = getPerformanceFrequency, | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 BADIM-PC\Vadim
					BADIM-PC\Vadim