Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hey,

I finally found a solution to the lockfile problem. The attached patch
prevents lockfiles during unit tests.

I did not push that patch directly because I'm not sure if we really
want to introduce another registry entry for this.

If this is the correct patch i would like to push that to master and
3-5 to prevent test failures because of old lockfiles. This brings us
now one step closer to a read-only source tree.

Regards,
Markus
From 2fe17e493046b9ecb58e3886d1f8cd27250f32b5 Mon Sep 17 00:00:00 2001
From: Markus Mohrhard <markus.mohrhard@googlemail.com>
Date: Fri, 13 Jan 2012 03:34:28 +0100
Subject: [PATCH] don't create lock files for unit tests

special thanks to Stephan for the configuration part
---
 .../schema/org/openoffice/Office/Common.xcs        |    7 ++++
 sfx2/source/doc/docfile.cxx                        |   30 ++++++++++++++++++++
 test/user-template/registry/modifications.xcd      |   10 ++++++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 2cee667..c74e508 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -6269,6 +6269,13 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="UseLocking" oor:type="xs:boolean">
+        <info>
+          <desc>Allows to specify whether locking should be used at all.
+          Use this setting only for debugging purpose.</desc>
+        </info>
+        <value>true</value>
+      </prop>
       <prop oor:name="ShowLinkWarningDialog" oor:type="xs:boolean">
         <info>
           <author>THB</author>
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 0332493..6d06057 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -204,6 +204,31 @@ sal_Bool IsOOoLockFileUsed()
     return bOOoLockFileUsed;
 }
 
+bool IsLockingUsed()
+{
+    bool bLocking = true;
+    try
+    {
+
+        uno::Reference< uno::XInterface > xCommonConfig = 
::comphelper::ConfigurationHelper::openConfig(
+                            ::comphelper::getProcessServiceFactory(),
+                            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
"/org.openoffice.Office.Common" ) ),
+                            ::comphelper::ConfigurationHelper::E_STANDARD );
+        if ( !xCommonConfig.is() )
+            throw uno::RuntimeException();
+
+        ::comphelper::ConfigurationHelper::readRelativeKey(
+                xCommonConfig,
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLocking" ) ) ) >>= bLocking;
+    }
+    catch( const uno::Exception& )
+    {
+    }
+
+    return bLocking;
+}
+
 } // anonymous namespace
 //==========================================================
 
@@ -998,6 +1023,11 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
     // if user cancel the loading the ERROR_ABORT is set
     sal_Bool bResult = sal_False;
 
+    if (!IsLockingUsed())
+    {
+        return sal_True;
+    }
+
     if ( !GetURLObject().HasError() ) try
     {
         if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( 
GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
diff --git a/test/user-template/registry/modifications.xcd 
b/test/user-template/registry/modifications.xcd
index d323645..87cacf7 100644
--- a/test/user-template/registry/modifications.xcd
+++ b/test/user-template/registry/modifications.xcd
@@ -27,6 +27,16 @@
  * instead of those above.
 -->
 <oor:data xmlns:oor="http://openoffice.org/2001/registry";>
+ <oor:component-data oor:name="Common" oor:package="org.openoffice.Office">
+  <node oor:name="Misc">
+    <prop oor:name="UseDocumentSystemFileLocking">
+      <value>false</value>
+    </prop>
+    <prop oor:name="UseDocumentOOoLockFile">
+      <value>false</value>
+    </prop>
+  </node>
+ </oor:component-data>
  <oor:component-data oor:name="Paths" oor:package="org.openoffice.Office">
   <node oor:name="Paths">
    <node oor:name="UIConfig" oor:op="replace">
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.