Index: SciTEGTK.cxx
===================================================================
RCS file: /cvsroot/scintilla/scite/gtk/SciTEGTK.cxx,v
retrieving revision 1.334
diff -a -u -r1.334 SciTEGTK.cxx
--- SciTEGTK.cxx	20 Jun 2007 12:11:41 -0000	1.334
+++ SciTEGTK.cxx	25 Jun 2007 19:15:07 -0000
@@ -455,7 +455,7 @@
 
 	static void ReadPipe(gpointer data, gint source, GdkInputCondition condition);
 	void SendFileName(int sendPipe, const char* filename);
-	void CheckForRunningInstance(int argc, char* argv[]);
+	bool CheckForRunningInstance(int argc, char* argv[]);
 
 	// GTK+ Signal Handlers
 
@@ -2106,22 +2106,13 @@
 
 void SciTEGTK::QuitProgram() {
 	if (SaveIfUnsureAll() != IDCANCEL) {
-
-#ifndef NO_FILER
-		int fdPipe = props.GetInt("scite.ipc_fdpipe");
-		if (fdPipe != -1) {
-			close(fdPipe);
-			unlink(props.Get("scite.ipc_name").c_str());
-		}
-#else
 		//clean up any pipes that are ours
 		if (pipeFD != -1) {
 			//printf("Cleaning up pipe\n");
 			close(pipeFD);
 			unlink(pipeName);
 		}
-#endif
-		gtk_exit(0);
+		gtk_main_quit();
 	}
 }
 
@@ -2132,19 +2123,7 @@
 }
 
 gint SciTEGTK::QuitSignal(GtkWidget *, GdkEventAny *, SciTEGTK *scitew) {
-	if (scitew->SaveIfUnsureAll() != IDCANCEL) {
-
-		//clean up any pipes that are ours
-		if (scitew->pipeFD != -1) {
-			//printf("Cleaning up pipe\n");
-			close(scitew->pipeFD);
-			unlink(scitew->pipeName);
-
-		}
-		gtk_exit(0);
-	}
-	// No need to return FALSE for quit as gtk_exit will have been called
-	// if needed.
+	scitew->QuitProgram();
 	return TRUE;
 }
 
@@ -3267,7 +3246,7 @@
 		perror("Unable to write to pipe");
 }
 
-void SciTEGTK::CheckForRunningInstance(int argc, char *argv[]) {
+bool SciTEGTK::CheckForRunningInstance(int argc, char *argv[]) {
 
 	// Use ipc.scite.name for the pipe name if it exists.
 	const SString pipeFilename = props.Get("ipc.scite.name");
@@ -3289,7 +3268,7 @@
 
 		// Force the SciTE instance to come to the front.
 		SendFileName(sendPipe, "");
-		gtk_exit(0);
+		return true;
 	}
 
 	// If pipe doesn't exist, create it.  If pipe exists without a
@@ -3298,7 +3277,7 @@
 		MakePipe(pipeName);
 	else if (errno != ENXIO) {
 		perror("Unable to open pipe as writer");
-		gtk_exit(0);
+		return true;
 	}
 
 	// Now open it as a reader to receive data.
@@ -3306,11 +3285,12 @@
 	if (pipeFD == -1) {
 		perror("Unable to open pipe as reader");
 		unlink(pipeName);
-		gtk_exit(0);
+		return true;
 	}
 
 	// Handler to read data.
 	gdk_input_add(pipeFD, GDK_INPUT_READ, ReadPipe, this);
+	return false;
 }
 
 void SciTEGTK::Run(int argc, char *argv[]) {
@@ -3335,9 +3315,13 @@
 	// Process any initial switches
 	ProcessCommandLine(args, 0);
 
-	// Check if SciTE is already running.  This could exit the program.
-	if ((props.Get("ipc.director.name").size() == 0) && props.GetInt ("check.if.already.open"))
-		CheckForRunningInstance (argc, argv);
+	// Check if SciTE is already running.
+	if ((props.Get("ipc.director.name").size() == 0) && props.GetInt ("check.if.already.open")) {
+		if (CheckForRunningInstance (argc, argv)) {
+			// Returning from this function exits the program.
+			return;
+		}
+	}
 
 	CreateUI();
 
