diff --git a/src/input/input.cpp b/src/input/input.cpp index f4373a1b..e25ba01d 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -677,6 +678,8 @@ struct InputPrivate /* Collective binding array */ std::vector bindings; + std::string clipboardText; + ButtonState stateArray[BUTTON_CODE_COUNT*2]; ButtonState *states; @@ -1493,11 +1496,10 @@ void Input::clearText() const char *Input::getClipboardText() { - // FIXME: this doesn't appear to be freed anywhere const char *tx = SDL_GetClipboardText(); - if (!tx) - throw Exception(Exception::SDLError, "Failed to get clipboard text: %s", SDL_GetError()); - return tx; + p->clipboardText = tx; + SDL_free((void *)tx); + return p->clipboardText.c_str(); } void Input::setClipboardText(const char *text) diff --git a/tools/embedtool.cpp b/tools/embedtool.cpp index caa08df8..17bd3a15 100644 --- a/tools/embedtool.cpp +++ b/tools/embedtool.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) { return 3; } - outputf << "#include \n#include \nextern const uint8_t " << arrayname << "[] = {"; + outputf << "#ifndef MKXPZ_EMBEDTOOL_" << arrayname << "\n#define MKXPZ_EMBEDTOOL_" << arrayname << "\n#include \n#include \n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst uint8_t " << arrayname << "[] = {"; uint64_t len = 0; for (;;) { @@ -53,7 +53,7 @@ int main(int argc, char **argv) { ++len; } - outputf << "};\nextern const size_t " << arrayname << "_len = " << len << "ULL;"; + outputf << "};\n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst size_t " << arrayname << "_len = " << len << "ULL;\n#endif /* MKXPZ_EMBEDTOOL_" << arrayname << " */\n"; return 0; }