]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/watchbsp.cpp
Merge commit '173f350be76237a7dee9c00c389dff4e56b3da4c' into garux-merge
[xonotic/netradiant.git] / radiant / watchbsp.cpp
index ada5eb435b0c32bff74537c08f6b32d595c54ae4..118d37f47ab950e98812c74b2b44599103d9e00f 100644 (file)
@@ -190,7 +190,7 @@ void Build_constructPage( PreferenceGroup& group ){
        Build_constructPreferences( page );
 }
 void Build_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Build_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) );
 }
 
 #include "preferencesystem.h"
@@ -201,16 +201,17 @@ void BuildMonitor_Construct(){
 
        g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" );
 
-       GlobalPreferenceSystem().registerPreference( "WatchBSP", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) );
-       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) );
-       GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) );
-       GlobalPreferenceSystem().registerPreference( "SleepMode", BoolImportStringCaller( g_WatchBSP_DoSleep ), BoolExportStringCaller( g_WatchBSP_DoSleep ) );
+       GlobalPreferenceSystem().registerPreference( "WatchBSP", make_property_string( g_WatchBSP_Enabled ) );
+       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", make_property_string( g_WatchBSP_RunQuake ) );
+       GlobalPreferenceSystem().registerPreference( "LeakStop", make_property_string( g_WatchBSP_LeakStop ) );
+       GlobalPreferenceSystem().registerPreference( "SleepMode", make_property_string( g_WatchBSP_DoSleep ) );
 
        Build_registerPreferencesPage();
 }
 
 void BuildMonitor_Destroy(){
        delete g_pWatchBSP;
+       g_pWatchBSP = NULL;
 }
 
 CWatchBSP *GetWatchBSP(){
@@ -469,7 +470,7 @@ static xmlSAXHandler saxParser = {
 // ------------------------------------------------------------------------------------------------
 
 
-guint s_routine_id;
+guint s_routine_id = 0;
 static gint watchbsp_routine( gpointer data ){
        reinterpret_cast<CWatchBSP*>( data )->RoutineProcessing();
        return TRUE;
@@ -489,8 +490,9 @@ void CWatchBSP::Reset(){
                m_xmlInputBuffer = NULL;
        }
        m_eState = EIdle;
-       if ( s_routine_id ) {
+       if ( s_routine_id != 0 ) {
                g_source_remove( s_routine_id );
+               s_routine_id = 0;
        }
 }
 
@@ -516,7 +518,7 @@ void CWatchBSP::DoEBeginStep(){
        if ( SetupListening() == false ) {
                const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n";
                globalOutputStream() << msg;
-               MainFrame_getWindow().alert( msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+               ui::alert( MainFrame_getWindow(), msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                return;
        }
        // set the timer for timeouts and step cancellation
@@ -533,7 +535,7 @@ void CWatchBSP::DoEBeginStep(){
                        msg << reinterpret_cast<const char*>( g_ptr_array_index( m_pCmd, m_iCurrentStep ) );
                        msg << "\nCheck that the file exists and that you don't run out of system resources.\n";
                        globalOutputStream() << msg.c_str();
-                       MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+                       ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                        return;
                }
                // re-initialise the debug window
@@ -613,7 +615,7 @@ void CWatchBSP::RoutineProcessing(){
        case EBeginStep:
                // timeout: if we don't get an incoming connection fast enough, go back to idle
                if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) {
-                       MainFrame_getWindow().alert(  "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
+                       ui::alert( MainFrame_getWindow(), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
                        EndMonitoringLoop();
 #if 0
                        if ( m_bBSPPlugin ) {
@@ -746,7 +748,7 @@ void CWatchBSP::RoutineProcessing(){
                                                        StringOutputStream msg;
                                                        msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
                                                        globalOutputStream() << msg.c_str();
-                                                       MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+                                                       ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                                                }
                                        }
                                        EndMonitoringLoop();
@@ -774,7 +776,7 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){
        if ( m_eState != EIdle ) {
                globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n";
                // prompt the user, should we cancel the current process and go ahead?
-               if ( MainFrame_getWindow().alert( "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
+               if ( ui::alert( MainFrame_getWindow(), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
                                                         "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) {
                        // disconnect and set EIdle state
                        Reset();