diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-11-08 16:17:47 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-11-08 16:21:04 +0100 |
commit | b1f0e0298c71475a0d8bc17976cb7ae39e3acb93 (patch) | |
tree | 52f68b2128cfd56b9909dd6fbc7347c5427220c8 | |
parent | 164ac84e28df50911a8c20f78119d05e21086c6c (diff) |
Restart soffice.bin when necessary.
In some cases, like when the migration is in progress, or when new extensions
are registered, soffice.bin dies with a 'restart' me status. This implements
the correct handling of this state in oosplash.bin.
-rw-r--r-- | desktop/scripts/soffice.sh | 5 | ||||
-rw-r--r-- | desktop/source/app/app.cxx | 7 | ||||
-rw-r--r-- | desktop/unx/source/start.c | 69 | ||||
-rw-r--r-- | desktop/unx/splash/unxsplash.cxx | 7 |
4 files changed, 58 insertions, 30 deletions
diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index ba8b8747c5f7..d6d316d05c0e 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -84,11 +84,10 @@ done if [ "$sd_binary" = "soffice.bin" -a -x "$sd_prog/oosplash.bin" ] && [ "$no_oosplash" != "y" ] ; then sd_binary="oosplash.bin" - export QSTART_CHECK_ONLY=1 - if "$sd_prog/$sd_binary" -qsend-and-report $*; then + # try to connect to a running instance early + if "$sd_prog/$sd_binary" -qsend-and-report "$@" ; then exit 0 fi - unset QSTART_CHECK_ONLY fi # pagein diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 0b85d03dc70f..3dc534ab7976 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1465,7 +1465,11 @@ USHORT Desktop::Exception(USHORT nError) OfficeIPCThread::DisableOfficeIPCThread(); if( pSignalHandler ) osl_removeSignalHandler( pSignalHandler ); + restartOnMac(false); + if ( m_rSplashScreen.is() ) + m_rSplashScreen->reset(); + _exit( ExitHelper::E_CRASH_WITH_RESTART ); } else @@ -1972,6 +1976,9 @@ void Desktop::Main() if ( bRestartRequested ) { restartOnMac(true); + if ( m_rSplashScreen.is() ) + m_rSplashScreen->reset(); + // wouldn't the solution be more clean if SalMain returns the exit code to the system? _exit( ExitHelper::E_NORMAL_RESTART ); } diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c index 022046abcd4f..84f80d457630 100644 --- a/desktop/unx/source/start.c +++ b/desktop/unx/source/start.c @@ -60,6 +60,8 @@ #define PIPEDEFAULTPATH "/tmp" #define PIPEALTERNATEPATH "/var/tmp" +typedef enum { ProgressContinue, ProgressRestart, ProgressExit } ProgressStatus; + /* Easier conversions: rtl_uString to rtl_String */ static rtl_String * ustr_to_str( rtl_uString *pStr ) @@ -531,7 +533,7 @@ load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash ) #define BUFFER_LEN 255 /* Read the percent to show in splash. */ -static sal_Bool +static ProgressStatus read_percent( int status_fd, int *pPercent ) { static char pBuffer[BUFFER_LEN + 1]; @@ -570,16 +572,19 @@ read_percent( int status_fd, int *pPercent ) fprintf( stderr, "Got status: %s\n", pBegin ); #endif if ( !strncasecmp( pBegin, "end", 3 ) ) - return sal_False; + return ProgressExit; + else if ( !strncasecmp( pBegin, "restart", 7 ) ) + return ProgressRestart; else if ( sscanf( pBegin, "%d%%", pPercent ) ) - return sal_True; + return ProgressContinue; - return sal_False; + /* unexpected - let's exit the splash to be safe */ + return ProgressExit; } /* Periodically update the splash & the percent acconding to what status_fd says */ -static void +static ProgressStatus show_splash( int status_fd ) { int nRetval; @@ -587,6 +592,7 @@ show_splash( int status_fd ) int nPercent = 0; sal_Bool bFinish = sal_False; + ProgressStatus eResult; /* we want to watch status_fd */ aPfd.fd = status_fd; @@ -605,10 +611,19 @@ show_splash( int status_fd ) if ( aPfd.revents & ( POLLERR | POLLHUP | POLLNVAL ) ) bFinish = sal_True; else if ( nRetval > 0 ) - bFinish = !read_percent( status_fd, &nPercent ); + { + eResult = read_percent( status_fd, &nPercent ); + bFinish = ( eResult != ProgressContinue ); + } else if ( nRetval < 0 ) bFinish = sal_True; } while ( !bFinish ); + +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "Finishing, result is %s\n", + ( eResult == ProgressContinue )? "continue" : ( ( eResult == ProgressRestart )? "restart" : "exit" ) ); +#endif + return eResult; } /* Simple system check. */ @@ -779,6 +794,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) sal_Bool bSentArgs = sal_False; rtl_uString *pAppPath = NULL; rtl_uString *pPipePath = NULL; + ProgressStatus eResult = ProgressExit; /* turn SIGPIPE into an error */ signal( SIGPIPE, SIG_IGN ); @@ -793,7 +809,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) } ustr_debug( "App path", pAppPath ); - bSendAndReport = argc > 1 && !strcmp (argv[1], "-qsend-and-report"); + bSendAndReport = argc > 1 && !strcmp (argv[1], QSEND_AND_REPORT); pPipePath = get_pipe_path( pAppPath ); @@ -809,26 +825,28 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) ustr_debug( "Failed to connect to pipe", pPipePath ); #endif - if (bSendAndReport) - return !bSentArgs; - - if ( !bSentArgs ) + if ( !bSendAndReport && !bSentArgs ) { - if ( !fork_app( pAppPath, &status_fd ) ) - return 1; + /* we have to exec the binary */ + do { + if ( !fork_app( pAppPath, &status_fd ) ) + return 1; - if ( !bInhibitSplash ) - { - load_splash_image( pAppPath ); - load_splash_defaults( pAppPath, &bInhibitSplash ); - } + if ( !bInhibitSplash ) + { + load_splash_image( pAppPath ); + load_splash_defaults( pAppPath, &bInhibitSplash ); + } - if ( !bInhibitSplash && splash_create_window( argc, argv ) ) - { - splash_draw_progress( 0 ); - show_splash( status_fd ); - splash_close_window(); - } + if ( !bInhibitSplash && splash_create_window( argc, argv ) ) + { + splash_draw_progress( 0 ); + eResult = show_splash( status_fd ); + splash_close_window(); + } + + close( status_fd ); + } while ( eResult == ProgressRestart ); } /* cleanup */ @@ -836,9 +854,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv ) rtl_uString_release( pPipePath ); close( fd ); - close( status_fd ); - return 0; + return bSendAndReport? !bSentArgs : 0; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/unx/splash/unxsplash.cxx b/desktop/unx/splash/unxsplash.cxx index 7db15a898777..6c1501416322 100644 --- a/desktop/unx/splash/unxsplash.cxx +++ b/desktop/unx/splash/unxsplash.cxx @@ -84,7 +84,12 @@ void SAL_CALL UnxSplashScreen::end() void SAL_CALL UnxSplashScreen::reset() throw ( RuntimeException ) { - // TODO? +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "UnxSplashScreen::reset()\n" ); +#endif + + fprintf( m_pOutFd, "restart\n" ); + fflush( m_pOutFd ); } void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ ) |