#include "referencecache.h"
#include "texwindow.h"
+#if GDEF_OS_WINDOWS
+#include <process.h>
+#else
+#include <spawn.h>
+#endif
+
#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
#define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget) g_object_set_data( G_OBJECT( window ), "glwidget", G_OBJECT( widget ) )
void GLWindow_Destroy(){
}
+
+void Radiant_Restart(){
+ // preferences are expected to be already saved in any way
+ // this is just to be sure and be future proof
+ Preferences_Save();
+
+ // this asks user for saving if map is modified
+ // user can chose to not save, it's ok
+ ConfirmModified( "Restart " RADIANT_NAME );
+
+ int status;
+
+ char *argv[ 3 ];
+ char exe_file[ 256 ];
+ char map_file[ 256 ];
+ bool with_map = false;
+
+ strncpy( exe_file, g_strAppFilePath.c_str(), 256 );
+
+ if ( !Map_Unnamed( g_map ) ) {
+ strncpy( map_file, Map_Name( g_map ), 256 );
+ with_map = true;
+ }
+
+ argv[ 0 ] = exe_file;
+ argv[ 1 ] = with_map ? map_file : NULL;
+ argv[ 2 ] = NULL;
+
+#if GDEF_OS_WINDOWS
+ status = !_spawnvpe( P_NOWAIT, exe_file, argv, environ );
+#else
+ pid_t pid;
+
+ status = posix_spawn( &pid, exe_file, NULL, NULL, argv, environ );
+#endif
+
+ // quit if radiant successfully started
+ if ( status == 0 ) {
+ gtk_main_quit();
+ }
+}
void MainFrame_Construct();
void MainFrame_Destroy();
+extern char **environ;
+void Radiant_Restart();
extern float ( *GridStatus_getGridSize )();
extern int ( *GridStatus_getRotateIncrement )();
if ( !g_restart_required.empty() ) {
StringOutputStream message( 256 );
message << "Preference changes require a restart:\n";
+
for ( std::vector<const char*>::iterator i = g_restart_required.begin(); i != g_restart_required.end(); ++i )
{
message << ( *i ) << '\n';
}
+
ui::alert( MainFrame_getWindow(), message.c_str() );
g_restart_required.clear();
}