#include <process.h>
#endif
+#define MAX_MESSAGE_LEN 2048
+
MULTI_DEBUG_CHANNEL(qemu, qt5_msgbox);
static const char * const icon_types[] = {
void start_qt5_msgbox(qt5_msgbox_icon icon, const char *message)
{
+ INFO("qt5_msgbox starts... \n");
+
+ if (message[0] == '\n' && strnlen(message, MAX_MESSAGE_LEN) == 1) {
+ ERR("The message has only a new-line character. \n" );
+ return;
+ }
+
char *app_path = get_app_path();
const char *title = "Emulator";
const char *argv[] = {app_path, icon_types[icon], title, message, NULL};
#ifdef CONFIG_WIN32
- INFO("qt5_msgbox starts... \n");
- if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1)
- ERR("qt5_msgbox can not be executed \n");
+ if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1) {
+ ERR("qt5_msgbox can not be executed. \n");
+ g_free(app_path);
+ return;
+ }
#else
pid_t child_pid = fork();
if (child_pid == 0) {
- INFO("qt5_msgbox starts... \n");
- if(execvp(app_path, (char * const *) argv) == -1)
- ERR("qt5_msgbox can not be executed \n");
+ if (execvp(app_path, (char * const *) argv) == -1) {
+ ERR("qt5_msgbox can not be executed. \n");
+ g_free(app_path);
+ return;
+ }
exit(0);
} else if (child_pid == -1) {
- ERR("qt5_msgbox can not be executed \n");
+ ERR("child process for qt5_msgbox can not be created. \n");
+ g_free(app_path);
+ return;
}
#endif
g_free(app_path);