qt5_msgbox: fix the bug of an abnormal execution in Windows
authorWon Jihye <jihye.won1@samsung.com>
Wed, 16 Dec 2015 08:44:54 +0000 (17:44 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 14 Jan 2016 12:03:56 +0000 (21:03 +0900)
_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 <jihye.won1@samsung.com>
tizen/src/util/qt5_error_report.c
tizen/standalone-src/qt5_msgbox.cpp

index e3ff10c3ac4c17f363a6ae93c3d07b2064430349..bffd329931400166b793256d8c4b7b8710d24502 100644 (file)
@@ -37,7 +37,8 @@
 #include "emul_state.h"
 
 #ifdef CONFIG_WIN32
-#include <process.h>
+#include <stdio.h>
+#include <windows.h>
 #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) {
index 6c914b137f1c53efe5fe7f0787af3db2bcd014d4..c42227620fe0d6118f93206d81c95f7d0a583dcd 100644 (file)
@@ -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();
 }