Author: jsc
Date: Thu Jul 19 15:03:14 2012
New Revision: 1363360

URL: http://svn.apache.org/viewvc?rev=1363360&view=rev
Log:
#119950 merge fix from trunk

Modified:
    incubator/ooo/branches/AOO34/main/desktop/inc/app.hxx
    incubator/ooo/branches/AOO34/main/desktop/source/app/app.cxx
    incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.cxx
    incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.hxx

Modified: incubator/ooo/branches/AOO34/main/desktop/inc/app.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/desktop/inc/app.hxx?rev=1363360&r1=1363359&r2=1363360&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/desktop/inc/app.hxx (original)
+++ incubator/ooo/branches/AOO34/main/desktop/inc/app.hxx Thu Jul 19 15:03:14 
2012
@@ -74,6 +74,7 @@ class Desktop : public Application
             BE_LANGUAGE_MISSING,
             BE_USERINSTALL_NOTENOUGHDISKSPACE,
             BE_USERINSTALL_NOWRITEACCESS,
+            BE_MUTLISESSION_NOT_SUPPROTED,
             BE_OFFICECONFIG_BROKEN
                };
         enum BootstrapStatus

Modified: incubator/ooo/branches/AOO34/main/desktop/source/app/app.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/desktop/source/app/app.cxx?rev=1363360&r1=1363359&r2=1363360&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/desktop/source/app/app.cxx (original)
+++ incubator/ooo/branches/AOO34/main/desktop/source/app/app.cxx Thu Jul 19 
15:03:14 2012
@@ -243,6 +243,8 @@ static sal_Bool _bCrashReporterEnabled =
 static const ::rtl::OUString CFG_PACKAGE_COMMON_HELP   ( 
RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Help"));
 
 static ::rtl::OUString getBrandSharePreregBundledPathURL();
+// #i119950# Add a option that not to display the "Fatal Error" on dialog title
+void FatalError(const ::rtl::OUString& sMessage, const sal_Bool 
isDisplayErrorString = sal_True);
 // ----------------------------------------------------------------------------
 
 ResMgr* Desktop::GetDesktopResManager()
@@ -354,7 +356,7 @@ OUString MakeStartupConfigAccessErrorMes
 //
 // Thats why we have to use a special native message box here which does not 
use yield :-)
 //=============================================================================
-void FatalError(const ::rtl::OUString& sMessage)
+void FatalError(const ::rtl::OUString& sMessage, const sal_Bool 
isDisplayErrorString)
 {
     ::rtl::OUString sProductKey = ::utl::Bootstrap::getProductKey();
     if ( ! sProductKey.getLength())
@@ -369,8 +371,9 @@ void FatalError(const ::rtl::OUString& s
 
     ::rtl::OUStringBuffer sTitle (128);
     sTitle.append      (sProductKey     );
-    sTitle.appendAscii (" - Fatal Error");
-
+       if (isDisplayErrorString) {
+               sTitle.appendAscii (" - Fatal Error");
+       }
     Application::ShowNativeErrorBox (sTitle.makeStringAndClear (), sMessage);
     _exit(ExitHelper::E_FATAL_ERROR);
 }
@@ -995,6 +998,11 @@ void Desktop::Init()
         if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR )
         {
             SetBootstrapError( BE_PATHINFO_MISSING );
+                       
+        }
+        else if ( aStatus == OfficeIPCThread::IPC_STATUS_MULTI_TS_ERROR )
+        {
+            SetBootstrapError( BE_MUTLISESSION_NOT_SUPPROTED );
         }
         else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
         {
@@ -1241,7 +1249,13 @@ void Desktop::HandleBootstrapPathErrors(
 
 void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
 {
-    if ( aBootstrapError == BE_PATHINFO_MISSING )
+       if ( aBootstrapError == BE_MUTLISESSION_NOT_SUPPROTED ) {
+               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;

Modified: 
incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.cxx?rev=1363360&r1=1363359&r2=1363360&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.cxx 
(original)
+++ incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.cxx 
Thu Jul 19 15:03:14 2012
@@ -496,16 +496,29 @@ OfficeIPCThread::Status OfficeIPCThread:
        do
        {
                OSecurity &rSecurity = Security::get();
-               // Try to create pipe
-               if ( pThread->maPipe.create( pThread->maPipeIdent.getStr(), 
OPipe::TOption_Create, rSecurity ))
+               // #119950# Try to connect pipe first. If connected, means 
another instance already launched.
+               if( pThread->maPipe.create( pThread->maPipeIdent.getStr(), 
OPipe::TOption_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
+                       // OpenOffice 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.
+                       vos::OPipe      maSessionPipe;
+                       if ( maSessionPipe.create( 
pThread->maPipeIdent.getStr(), OPipe::TOption_Create, 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 {
+                               // Pipe connected to first office
+                               nPipeMode = PIPEMODE_CONNECTED;
+                       }
+
                }
-               else if( pThread->maPipe.create( pThread->maPipeIdent.getStr(), 
OPipe::TOption_Open, rSecurity )) // Creation not successfull, now we try to 
connect
+               else if ( pThread->maPipe.create( 
pThread->maPipeIdent.getStr(), OPipe::TOption_Create, rSecurity )) // 
Connection not successfull, now we try to create
                {
-                       // Pipe connected to first office
-                       nPipeMode = PIPEMODE_CONNECTED;
+                       // Pipe created
+                       nPipeMode = PIPEMODE_CREATED;
                }
                else
                {

Modified: 
incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.hxx?rev=1363360&r1=1363359&r2=1363360&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.hxx 
(original)
+++ incubator/ooo/branches/AOO34/main/desktop/source/app/officeipcthread.hxx 
Thu Jul 19 15:03:14 2012
@@ -107,7 +107,8 @@ class OfficeIPCThread : public vos::OThr
        {
                IPC_STATUS_OK,
                IPC_STATUS_2ND_OFFICE,
-               IPC_STATUS_BOOTSTRAP_ERROR
+               IPC_STATUS_BOOTSTRAP_ERROR,
+               IPC_STATUS_MULTI_TS_ERROR
        };
 
        virtual ~OfficeIPCThread();


Reply via email to