[Libreoffice-commits] core.git: 2 commits - desktop/inc desktop/source

Ariel Constenla-Haile arielch at apache.org
Tue Jul 30 07:01:56 PDT 2013


 desktop/inc/app.hxx                    |    1 
 desktop/source/app/app.cxx             |   22 +++++++++++---
 desktop/source/app/desktop.hrc         |    1 
 desktop/source/app/desktop.src         |    5 +++
 desktop/source/app/officeipcthread.cxx |   51 ++++++++++++++++++++-------------
 desktop/source/app/officeipcthread.hxx |    3 +
 6 files changed, 59 insertions(+), 24 deletions(-)

New commits:
commit a220c2dbb8f05ee6bba6d5baf660a7339a7d2c71
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Fri Jul 20 01:48:09 2012 +0000

    Fix build breaker: add missing string resource
    (cherry picked from commit c5a4e46fab045ae8abe01cbfd397806a58039d8a)

diff --git a/desktop/source/app/desktop.hrc b/desktop/source/app/desktop.hrc
index 18d66e4..e9caf4a 100644
--- a/desktop/source/app/desktop.hrc
+++ b/desktop/source/app/desktop.hrc
@@ -48,6 +48,7 @@
 #define STR_BOOTSTRAP_ERR_NO_CFG_SERVICE    (RID_DESKTOP_STRING_START+121)
 #define STR_BOOTSTRAP_ERR_CFG_DATAACCESS    (RID_DESKTOP_STRING_START+122)
 #define STR_BOOTSTRAP_ERR_NO_PATHSET_SERVICE (RID_DESKTOP_STRING_START+123)
+#define STR_BOOTSTRAP_ERR_MULTISESSION       (RID_DESKTOP_STRING_START+124)
 
 #define STR_ASK_START_SETUP_MANUALLY        (RID_DESKTOP_STRING_START+152)
 
diff --git a/desktop/source/app/desktop.src b/desktop/source/app/desktop.src
index 367bc12..383af8f 100644
--- a/desktop/source/app/desktop.src
+++ b/desktop/source/app/desktop.src
@@ -90,6 +90,11 @@ String STR_BOOTSTRAP_ERR_NO_CFG_SERVICE
     Text [ en-US ] = "The configuration service is not available.";
 };
 
+String STR_BOOTSTRAP_ERR_MULTISESSION
+{
+    Text [ en-US ] = "You have another instance running in a different terminal session. Close that instance and then try again.";
+};
+
 String STR_ASK_START_SETUP_MANUALLY
 {
     Text [ en-US ] = "Start the setup application to repair the installation from the CD or the folder containing the installation packages.";
commit b218cbf59de4d7ae0a6962995fb0f719ed68b5d2
Author: Jürgen Schmidt <jsc at apache.org>
Date:   Thu Jul 19 13:55:30 2012 +0000

    Fixing i#119950 warn about other running terminal sessions
    
    introduce new warning message box to inform about further running terminal sessions
    
    Patch By: Juan Li
    Review By: Jina Fang Zheng, jsc
    
    (cherry picked from commit 208b788dd4afc0559eb26c6e20a59548be0d993e)
    
    Conflicts:
    	desktop/source/app/app.cxx
    	desktop/source/app/officeipcthread.cxx
    	desktop/source/app/officeipcthread.hxx
    
    Change-Id: Icd858adaa0d2400eecba3c61c91e0c6fdb6d6af7

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index d949304..04153ef 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -64,6 +64,7 @@ class Desktop : public Application
             BE_LANGUAGE_MISSING,
             BE_USERINSTALL_NOTENOUGHDISKSPACE,
             BE_USERINSTALL_NOWRITEACCESS,
+            BE_MULTISESSION_NOT_SUPPORTED,
             BE_OFFICECONFIG_BROKEN
         };
         enum BootstrapStatus
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 96e244d..ba90725 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -415,7 +415,10 @@ OUString MakeStartupConfigAccessErrorMessage( OUString const & aInternalErrMsg )
 // are allowed. Otherwise we will force a "crash inside a crash".
 // Thats why we have to use a special native message box here which does not use yield :-)
 //=============================================================================
-void FatalError(const OUString& sMessage)
+
+// #i119950# Add a option that not to display the "Fatal Error" on dialog title
+void FatalError(const OUString& sMessage, const bool isDisplayErrorString = true);
+void FatalError(const OUString& sMessage, const bool isDisplayErrorString)
 {
     OUString sProductKey = ::utl::Bootstrap::getProductKey();
     if ( sProductKey.isEmpty())
@@ -429,8 +432,9 @@ void FatalError(const OUString& sMessage)
 
     OUStringBuffer sTitle (128);
     sTitle.append      (sProductKey     );
-    sTitle.appendAscii (" - Fatal Error");
-
+    if (isDisplayErrorString) {
+        sTitle.appendAscii (" - Fatal Error");
+    }
     Application::ShowNativeErrorBox (sTitle.makeStringAndClear (), sMessage);
     _exit(EXITHELPER_FATAL_ERROR);
 }
@@ -622,6 +626,10 @@ void Desktop::Init()
         {
             SetBootstrapError( BE_PATHINFO_MISSING, OUString() );
         }
+        else if ( aStatus == OfficeIPCThread::IPC_STATUS_MULTI_TS_ERROR )
+        {
+            SetBootstrapError( BE_MULTISESSION_NOT_SUPPORTED, OUString() );
+        }
         else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
         {
             // 2nd office startup should terminate after sending cmdlineargs through pipe
@@ -848,7 +856,13 @@ OUString    Desktop::CreateErrorMsgString(
 void Desktop::HandleBootstrapErrors(
     BootstrapError aBootstrapError, OUString const & aErrorMessage )
 {
-    if ( aBootstrapError == BE_PATHINFO_MISSING )
+    if ( aBootstrapError == BE_MULTISESSION_NOT_SUPPORTED ) {
+        OUString        aMessage;
+        aMessage = GetMsgString( STR_BOOTSTRAP_ERR_MULTISESSION,
+                        OUString( RTL_CONSTASCII_USTRINGPARAM( "You have another instance running in a different terminal session. Close that instance and then try again." )) );
+        FatalError(aMessage,sal_False);
+
+    } else if ( aBootstrapError == BE_PATHINFO_MISSING )
     {
         OUString                    aErrorMsg;
         OUString                    aBuffer;
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index db8a407..9113880 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -522,28 +522,41 @@ OfficeIPCThread::Status OfficeIPCThread::EnableOfficeIPCThread()
     do
     {
         osl::Security &rSecurity = Security::get();
-        // Try to create pipe
-        if ( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_CREATE, rSecurity ))
+        // #119950# Try to connect pipe first. If connected, means another instance already launched.
+        if ( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity ))
         {
-            // Pipe created
-            nPipeMode = PIPEMODE_CREATED;
+            // #119950# Test if launched in a new terminal session for same user. On Windows platform, normally a user is resticted
+            // to have only one terminal session. But if mutiple terminal session for one user is allowed, crash will happen if launched
+            // LibreOffice from more than one terminal session. So need to detect and prevent this happen.
+
+            // Will try to create a same name pipe. If creation is successfully, means current instance is launched in a new session.
+            osl::Pipe  aSessionPipe;
+            if ( aSessionPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity )) {
+                // Can create a pipe with same name. This can only happen in multiple terminal session environment on Windows platform.
+                // Will display a warning dialog and exit.
+                return IPC_STATUS_MULTI_TS_ERROR;
+            } else {
+                osl::StreamPipe aStreamPipe(pThread->maPipe.getHandle());
+                if (readStringFromPipe(aStreamPipe) == SEND_ARGUMENTS)
+                {
+                    // Pipe connected to first office
+                    nPipeMode = PIPEMODE_CONNECTED;
+                }
+                else
+                {
+                    // Pipe connection failed (other office exited or crashed)
+                    TimeValue tval;
+                    tval.Seconds = 0;
+                    tval.Nanosec = 500000000;
+                    salhelper::Thread::wait( tval );
+                }
+            }
+
         }
-        else if( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity )) // Creation not successful, now we try to connect
+        else if ( pThread->maPipe.create( aPipeIdent.getStr(), osl_Pipe_OPEN, rSecurity )) // Connection not successfull, now we try to create
         {
-            osl::StreamPipe aStreamPipe(pThread->maPipe.getHandle());
-            if (readStringFromPipe(aStreamPipe) == SEND_ARGUMENTS)
-            {
-                // Pipe connected to first office
-                nPipeMode = PIPEMODE_CONNECTED;
-            }
-            else
-            {
-                // Pipe connection failed (other office exited or crashed)
-                TimeValue tval;
-                tval.Seconds = 0;
-                tval.Nanosec = 500000000;
-                salhelper::Thread::wait( tval );
-            }
+            // Pipe created
+            nPipeMode = PIPEMODE_CREATED;
         }
         else
         {
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index a17e116..223e371 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -108,7 +108,8 @@ class OfficeIPCThread : public salhelper::Thread
         IPC_STATUS_OK,
         IPC_STATUS_2ND_OFFICE,
         IPC_STATUS_PIPE_ERROR,
-        IPC_STATUS_BOOTSTRAP_ERROR
+        IPC_STATUS_BOOTSTRAP_ERROR,
+        IPC_STATUS_MULTI_TS_ERROR
     };
 
     // controlling pipe communication during shutdown


More information about the Libreoffice-commits mailing list