From c6d2489fd0135d77ddf9b32c2563fe64b0f48610 Mon Sep 17 00:00:00 2001 From: Won Jihye Date: Wed, 16 Dec 2015 17:44:54 +0900 Subject: [PATCH] qt5_msgbox: fix the bug of an abnormal execution in Windows _spawnv function was changed into CreateProcess function to execute the program(qt5_msgbox). _spawnv eventually call CreateProcess because CreateProcess is Win32 API function. Also, CreateProcess gives us more control over the child processes. Although I can not find out the exact reason of the bug, I fixed the bug by using CreateProcess. Change-Id: Ib8d53df65da93460a2ac6c8e57bff660d14021ca Signed-off-by: Jihye Won --- tizen/src/util/qt5_error_report.c | 32 +++++++++++++++++++++++++---- tizen/standalone-src/qt5_msgbox.cpp | 1 + 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/tizen/src/util/qt5_error_report.c b/tizen/src/util/qt5_error_report.c index e3ff10c3ac..bffd329931 100644 --- a/tizen/src/util/qt5_error_report.c +++ b/tizen/src/util/qt5_error_report.c @@ -37,7 +37,8 @@ #include "emul_state.h" #ifdef CONFIG_WIN32 -#include +#include +#include #endif #define MAX_MESSAGE_LEN 2048 @@ -74,15 +75,38 @@ void start_qt5_msgbox(qt5_msgbox_icon icon, const char *message) char *app_path = get_app_path(); const char *title = "Emulator"; - const char *argv[] = {app_path, icon_types[icon], title, message, NULL}; #ifdef CONFIG_WIN32 - if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1) { - ERR("qt5_msgbox can not be executed. \n"); + char *arg = g_strdup_printf("%s.exe %s %s %s", app_path, icon_types[icon], title, message); + + PROCESS_INFORMATION process_info; + STARTUPINFO startup_info; + ZeroMemory(&startup_info, sizeof(startup_info)); + startup_info.cb = sizeof startup_info; + + if (!CreateProcess(NULL, // No module name (use command line) + arg, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + CREATE_NEW_PROCESS_GROUP, // Process Creation Flags + NULL, // Use parent's environment block + NULL, // USe parent's starting directory + &startup_info, // Pointer to STARTUPINFO structure + &process_info) // Pointer to PROCESS_INFORMATION structure + ) { + ERR("qt5_msgbox can not be executed. (%d) \n", GetLastError()); g_free(app_path); + g_free(arg); return; } + + // Close process and thread handles + CloseHandle(process_info.hProcess); + CloseHandle(process_info.hThread); + g_free(arg); #else + const char *argv[] = {app_path, icon_types[icon], title, message, NULL}; pid_t child_pid = fork(); if (child_pid == 0) { if (execvp(app_path, (char * const *) argv) == -1) { diff --git a/tizen/standalone-src/qt5_msgbox.cpp b/tizen/standalone-src/qt5_msgbox.cpp index 6c914b137f..c42227620f 100644 --- a/tizen/standalone-src/qt5_msgbox.cpp +++ b/tizen/standalone-src/qt5_msgbox.cpp @@ -84,6 +84,7 @@ static void createMsgBox(int argc, char *argv[]) QMessageBox::Ok); msgBox->setDefaultButton(QMessageBox::Ok); msgBox->setWindowModality(Qt::ApplicationModal); + msgBox->setWindowFlags(Qt::WindowStaysOnTopHint); msgBox->show(); } -- 2.34.1