[quake3-commits] r2092 - trunk/code/sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Jul 18 15:32:26 EDT 2011


Author: tma
Date: 2011-07-18 15:32:25 -0400 (Mon, 18 Jul 2011)
New Revision: 2092

Modified:
   trunk/code/sys/sys_unix.c
Log:
* Fix various issues with unix Sys_Dialog

Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c	2011-07-18 16:32:36 UTC (rev 2091)
+++ trunk/code/sys/sys_unix.c	2011-07-18 19:32:25 UTC (rev 2092)
@@ -555,10 +555,10 @@
 Sys_ZenityCommand
 ==============
 */
-static int Sys_ZenityCommand( dialogType_t type, const char *message, const char *title )	
+static void Sys_ZenityCommand( dialogType_t type, const char *message, const char *title,
+		char *command, size_t commandSize )
 {
 	const char *options = "";
-	char       command[ 1024 ];
 
 	switch( type )
 	{
@@ -570,10 +570,8 @@
 		case DT_OK_CANCEL: options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\""; break;
 	}
 
-	Com_sprintf( command, sizeof( command ), "zenity %s --text=\"%s\" --title=\"%s\"",
+	Com_sprintf( command, commandSize, "zenity %s --text=\"%s\" --title=\"%s\" >/dev/null 2>/dev/null",
 		options, message, title );
-
-	return system( command );
 }
 
 /*
@@ -581,10 +579,10 @@
 Sys_KdialogCommand
 ==============
 */
-static int Sys_KdialogCommand( dialogType_t type, const char *message, const char *title )
+static void Sys_KdialogCommand( dialogType_t type, const char *message, const char *title,
+		char *command, size_t commandSize )
 {
 	const char *options = "";
-	char       command[ 1024 ];
 
 	switch( type )
 	{
@@ -596,10 +594,8 @@
 		case DT_OK_CANCEL: options = "--warningcontinuecancel"; break;
 	}
 
-	Com_sprintf( command, sizeof( command ), "kdialog %s \"%s\" --title \"%s\"",
+	Com_sprintf( command, commandSize, "kdialog %s \"%s\" --title \"%s\" >/dev/null 2>/dev/null",
 		options, message, title );
-
-	return system( command );
 }
 
 /*
@@ -607,10 +603,10 @@
 Sys_XmessageCommand
 ==============
 */
-static int Sys_XmessageCommand( dialogType_t type, const char *message, const char *title )
+static void Sys_XmessageCommand( dialogType_t type, const char *message, const char *title,
+		char *command, size_t commandSize )
 {
 	const char *options = "";
-	char       command[ 1024 ];
 
 	switch( type )
 	{
@@ -619,10 +615,8 @@
 		case DT_OK_CANCEL: options = "-buttons OK:0,Cancel:1"; break;
 	}
 
-	Com_sprintf( command, sizeof( command ), "xmessage -center %s \"%s\"",
+	Com_sprintf( command, commandSize, "xmessage -center %s \"%s\" >/dev/null 2>/dev/null",
 		options, message );
-
-	return system( command );
 }
 
 /*
@@ -642,7 +636,7 @@
 		XMESSAGE,
 		NUM_DIALOG_PROGRAMS
 	} dialogCommandType_t;
-	typedef int (*dialogCommandBuilder_t)( dialogType_t, const char *, const char * );
+	typedef void (*dialogCommandBuilder_t)( dialogType_t, const char *, const char *, char *, size_t );
 
 	const char              *session = getenv( "DESKTOP_SESSION" );
 	qboolean                tried[ NUM_DIALOG_PROGRAMS ] = { qfalse };
@@ -662,7 +656,6 @@
 	while( 1 )
 	{
 		int i;
-		int exitCode;
 
 		for( i = NONE + 1; i < NUM_DIALOG_PROGRAMS; i++ )
 		{
@@ -671,14 +664,22 @@
 
 			if( !tried[ i ] )
 			{
-				exitCode = commands[ i ]( type, message, title );
+				int exitCode;
+				int childSignal;
+				int childCode;
+				char command[ 1024 ];
 
-				if( exitCode >= 0 )
+				commands[ i ]( type, message, title, command, sizeof( command ) );
+				exitCode = system( command );
+				childSignal = exitCode & 127;
+				childCode = exitCode >> 8;
+
+				if( exitCode != -1 && childSignal == 0 && childCode != 126 && childCode != 127 )
 				{
 					switch( type )
 					{
-						case DT_YES_NO:    return exitCode ? DR_NO : DR_YES;
-						case DT_OK_CANCEL: return exitCode ? DR_CANCEL : DR_OK;
+						case DT_YES_NO:    return childCode ? DR_NO : DR_YES;
+						case DT_OK_CANCEL: return childCode ? DR_CANCEL : DR_OK;
 						default:           return DR_OK;
 					}
 				}



More information about the quake3-commits mailing list