summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib/osdlib_uwp.cpp
diff options
context:
space:
mode:
author npwoods <npwoods@mess.org>2019-09-11 14:16:02 -0400
committer R. Belmont <rb6502@users.noreply.github.com>2019-09-11 14:16:02 -0400
commitbc15184c90a7eaf4cf16ea060916346e390a7c3b (patch)
treebdf475c68602c37cba55338702343f572bbed6ee /src/osd/modules/lib/osdlib_uwp.cpp
parent4f8928432a9db8cd46cfd5c6e2cb262eafaed9d2 (diff)
Changed osd_get_clipboard_text() to return std::string (#5615)
* Changed osd_get_clipboard_text() to return std::string This change has only been tested on Windows. The Un*x/Mac versions were made blindly; they might not even build. This needs to be checked prior to merging. * Fixing Mac OS X build (hopefully)
Diffstat (limited to 'src/osd/modules/lib/osdlib_uwp.cpp')
-rw-r--r--src/osd/modules/lib/osdlib_uwp.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/osd/modules/lib/osdlib_uwp.cpp b/src/osd/modules/lib/osdlib_uwp.cpp
index 7bfb594f9c7..8d20c552cab 100644
--- a/src/osd/modules/lib/osdlib_uwp.cpp
+++ b/src/osd/modules/lib/osdlib_uwp.cpp
@@ -129,7 +129,7 @@ void osd_break_into_debugger(const char *message)
// get_clipboard_text_by_format
//============================================================
-static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LPCVOID data))
+static bool get_clipboard_text_by_format(std::string &result_text, UINT format, std::string (*convert)(LPCVOID data))
{
DataPackageView^ dataPackageView;
IAsyncOperation<String^>^ getTextOp;
@@ -139,7 +139,8 @@ static char *get_clipboard_text_by_format(UINT format, std::string (*convert)(LP
getTextOp = dataPackageView->GetTextAsync();
clipboardText = getTextOp->GetResults();
- return (char *)convert(clipboardText->Data()).c_str();
+ result_text = convert(clipboardText->Data());
+ return !result_text.empty();
}
//============================================================
@@ -164,14 +165,16 @@ static std::string convert_ansi(LPCVOID data)
// osd_get_clipboard_text
//============================================================
-char *osd_get_clipboard_text(void)
+std::string osd_get_clipboard_text(void)
{
- // try to access unicode text
- char *result = get_clipboard_text_by_format(CF_UNICODETEXT, convert_wide);
+ std::string result;
- // try to access ANSI text
- if (result == nullptr)
- result = get_clipboard_text_by_format(CF_TEXT, convert_ansi);
+ // try to access unicode text
+ if (!get_clipboard_text_by_format(result, CF_UNICODETEXT, convert_wide))
+ {
+ // try to access ANSI text
+ get_clipboard_text_by_format(result, CF_TEXT, convert_ansi);
+ }
return result;
}