Skip to content

Commit 6af502d

Browse files
committed
refactor: Trim superfluous error handling in GUI message dialog
1 parent 8e01711 commit 6af502d

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/utils-win.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,13 @@ static HANDLE winerr_fh = NULL;
2323
void
2424
gui_message (const char *message)
2525
{
26-
gunichar2 *title, *body;
27-
GError *error = NULL;
28-
29-
title = g_utf8_to_utf16 (_("This is a command line application"),
30-
-1, NULL, NULL, &error);
31-
if (error) {
32-
g_clear_error (&error);
33-
title = g_utf8_to_utf16 ("This is a command line application",
34-
-1, NULL, NULL, NULL);
35-
}
26+
gunichar2 *title = L"This is a command line application";
27+
gunichar2 *body = g_utf8_to_utf16 (message, -1, NULL, NULL, NULL);
3628

37-
body = g_utf8_to_utf16 (message, -1, NULL, NULL, &error);
38-
if (error) {
39-
g_clear_error (&error);
40-
body = g_utf8_to_utf16 ("(Original message failed to be displayed in UTF-16)",
29+
if (body == NULL)
30+
body = g_utf8_to_utf16 ("(Failure to display help)",
4131
-1, NULL, NULL, NULL);
42-
}
4332

44-
/* Takes advantage of the fact that LPCWSTR (wchar_t) is actually 16bit on Windows */
4533
MessageBoxW (NULL, (LPCWSTR) body, (LPCWSTR) title,
4634
MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
4735
g_free (title);

0 commit comments

Comments
 (0)