Skip to content

Commit

Permalink
use warning icon in some cases on error message
Browse files Browse the repository at this point in the history
  • Loading branch information
oov committed Feb 27, 2024
1 parent 0c92b47 commit 5a74998
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/c/error_gcmz.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,23 @@ gcmz_error_format(error e, struct wstr *const dest, wchar_t const *const referen

struct error_message_box_task_data {
HWND window;
UINT flags;

struct wstr msg;
struct wstr title;
};

static void error_message_box_task(void *userdata) {
struct error_message_box_task_data *d = userdata;
message_box(d->window, d->msg.ptr, d->title.ptr, MB_ICONERROR);
message_box(d->window, d->msg.ptr, d->title.ptr, d->flags);
ereport(sfree(&d->title));
ereport(sfree(&d->msg));
ereport(mem_free(&d));
}

void gcmz_error_message_box(error e,
HWND const window,
UINT const flags,
bool const deferred,
char const *const title,
wchar_t const *const reference,
Expand Down Expand Up @@ -223,6 +225,7 @@ void gcmz_error_message_box(error e,
goto cleanup;
}
d->window = window;
d->flags = flags;
d->msg = msg;
msg = (struct wstr){0};
d->title = wide_title;
Expand Down
1 change: 1 addition & 0 deletions src/c/error_gcmz.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ NODISCARD error
gcmz_error_format(error e, struct wstr *const dest, wchar_t const *const reference, char const *const format, ...);
void gcmz_error_message_box(error e,
HWND const window,
UINT const flags,
bool const deferred,
char const *const title,
wchar_t const *const reference,
Expand Down
27 changes: 19 additions & 8 deletions src/c/gcmzdrops.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void generic_lua_error_handler(error e, char const *const default_msg) {
msg = default_msg;
cleanup:
if (msg) {
gcmz_error_message_box(e, aviutl_get_exedit_window_must(), true, gettext("Error"), NULL, "%1$s", msg);
gcmz_error_message_box(e, aviutl_get_exedit_window_must(), MB_ICONERROR, true, gettext("Error"), NULL, "%1$s", msg);
}
files_cleanup(true);
}
Expand Down Expand Up @@ -674,6 +674,7 @@ static void request_callback(struct api_request_params *const params, api_reques
if (efailed(err)) {
gcmz_error_message_box(err,
(HWND)params->userdata,
MB_ICONERROR,
false,
gettext("Error"),
NULL,
Expand Down Expand Up @@ -717,7 +718,7 @@ static BOOL wndproc_init(HWND const window) {
efree(&err);
}
gui_lock();
gcmz_error_message_box(err, window, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg);
gcmz_error_message_box(err, window, MB_ICONERROR, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg);
return FALSE;
}

Expand All @@ -734,8 +735,15 @@ static BOOL wndproc_init(HWND const window) {
err = drop_target_new(&dt);
if (efailed(err)) {
gui_lock();
gcmz_error_message_box(
err, window, false, title, L"%1$s%2$s", "%1$s\n\n%2$s", msg_head, gettext("Failed to create IDropTarget."));
gcmz_error_message_box(err,
window,
MB_ICONERROR,
false,
title,
L"%1$s%2$s",
"%1$s\n\n%2$s",
msg_head,
gettext("Failed to create IDropTarget."));
return FALSE;
}
dt->super.lpVtbl->AddRef((void *)dt);
Expand All @@ -759,7 +767,7 @@ static BOOL wndproc_init(HWND const window) {
efree(&err);
}
gui_lock();
gcmz_error_message_box(err, window, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg);
gcmz_error_message_box(err, window, MB_ICONERROR, false, title, NULL, msg ? "%1$s\n\n%2$s" : "%1$s", msg_head, msg);
return FALSE;
}
g_drop_target_registered = SUCCEEDED(hr);
Expand All @@ -768,6 +776,7 @@ static BOOL wndproc_init(HWND const window) {
if (efailed(err)) {
gcmz_error_message_box(err,
window,
MB_ICONWARNING,
false,
title,
NULL,
Expand All @@ -782,13 +791,15 @@ static BOOL wndproc_init(HWND const window) {
if (efailed(err)) {
char const *apimsg = NULL;
if (eis_hr(err, HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))) {
apimsg = gettext("This error mainly occurs when multiple instances of AviUtl are running.\n"
"If you need external integration API, please close all instances of AviUtl and start only one instance.\n"
"If you do not need external integration API, you can ignore this message.");
apimsg = gettext(
"This error mainly occurs when multiple instances of AviUtl are running.\n"
"If you need external integration API, please close all instances of AviUtl and start only one instance.\n"
"If you do not need external integration API, you can ignore this message.");
efree(&err);
}
gcmz_error_message_box(err,
window,
MB_ICONWARNING,
false,
title,
NULL,
Expand Down

0 comments on commit 5a74998

Please sign in to comment.