Kaydet (Commit) 7a67d7a7 authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

use more thread safe static initializer in postgresql driver

Change-Id: Idb210207112994e1247c35e0dce1c6cd2f80f371
Reviewed-on: https://gerrit.libreoffice.org/53365Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b4ba8dc9
......@@ -84,44 +84,34 @@ namespace pq_sdbc_driver
{
static ::cppu::IPropertyArrayHelper & getResultSetPropertyArrayHelper()
{
static ::cppu::IPropertyArrayHelper *pArrayHelper;
if( ! pArrayHelper )
{
MutexGuard guard( Mutex::getGlobalMutex() );
if( ! pArrayHelper )
{
static Property aTable[] =
{
// LEM TODO: this needs to be kept in sync with other, e.g. pq_statics.css:508
// Should really share!
// At least use for the handles the #define'd values in .hxx file...
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"IsBookmarkable", 4,
cppu::UnoType<bool>::get() , 0 ),
Property(
"ResultSetConcurrency", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 6,
::cppu::UnoType<sal_Int32>::get() , 0 )
};
static_assert( SAL_N_ELEMENTS(aTable) == BASERESULTSET_SIZE, "wrong number of elements" );
static ::cppu::OPropertyArrayHelper arrayHelper( aTable, BASERESULTSET_SIZE, true );
pArrayHelper = &arrayHelper;
}
}
// LEM TODO: this needs to be kept in sync with other, e.g. pq_statics.css:508
// Should really share!
// At least use for the handles the #define'd values in .hxx file...
static ::cppu::OPropertyArrayHelper arrayHelper(
Sequence<Property>{
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"IsBookmarkable", 4,
cppu::UnoType<bool>::get() , 0 ),
Property(
"ResultSetConcurrency", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 6,
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
static ::cppu::IPropertyArrayHelper *pArrayHelper = &arrayHelper;
return *pArrayHelper;
}
......@@ -176,20 +166,11 @@ Any BaseResultSet::queryInterface( const Type & rType )
Sequence<Type > BaseResultSet::getTypes()
{
static Sequence< Type > *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
BaseResultSet_BASE::getTypes()));
pCollection = &collection;
}
}
return *pCollection;
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
BaseResultSet_BASE::getTypes()));
return collection;
}
Sequence< sal_Int8> BaseResultSet::getImplementationId()
......
......@@ -39,8 +39,6 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
using osl::MutexGuard;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
......@@ -82,20 +80,12 @@ css::uno::Any FakedUpdateableResultSet::queryInterface(
css::uno::Sequence< css::uno::Type > FakedUpdateableResultSet::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<XResultSetUpdate>::get(),
cppu::UnoType<XRowUpdate>::get(),
ResultSet::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection s_collection(
cppu::UnoType<XResultSetUpdate>::get(),
cppu::UnoType<XRowUpdate>::get(),
ResultSet::getTypes());
return s_collection.getTypes();
}
......
......@@ -57,7 +57,6 @@
#include <connectivity/dbconversion.hxx>
using osl::Mutex;
using osl::MutexGuard;
......@@ -90,47 +89,38 @@ namespace pq_sdbc_driver
{
static ::cppu::IPropertyArrayHelper & getPreparedStatementPropertyArrayHelper()
{
static ::cppu::IPropertyArrayHelper *pArrayHelper;
if( ! pArrayHelper )
{
MutexGuard guard( Mutex::getGlobalMutex() );
if( ! pArrayHelper )
{
static Property aTable[] =
{
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxFieldSize", 4,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxRows", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"QueryTimeOut", 6,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetConcurrency", 7,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 8,
::cppu::UnoType<sal_Int32>::get() , 0 )
};
static_assert( SAL_N_ELEMENTS(aTable) == PREPARED_STATEMENT_SIZE, "wrong number of elements" );
static ::cppu::OPropertyArrayHelper arrayHelper( aTable, PREPARED_STATEMENT_SIZE, true );
pArrayHelper = &arrayHelper;
}
}
static ::cppu::OPropertyArrayHelper arrayHelper(
Sequence<Property>{
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxFieldSize", 4,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxRows", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"QueryTimeOut", 6,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetConcurrency", 7,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 8,
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
static ::cppu::IPropertyArrayHelper *pArrayHelper = &arrayHelper;
return *pArrayHelper;
}
......@@ -239,20 +229,12 @@ Any PreparedStatement::queryInterface( const Type & rType )
Sequence< Type > PreparedStatement::getTypes()
{
static Sequence< Type > *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
PreparedStatement_BASE::getTypes()));
pCollection = &collection;
}
}
return *pCollection;
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
PreparedStatement_BASE::getTypes()));
return collection;
}
Sequence< sal_Int8> PreparedStatement::getImplementationId()
......
......@@ -67,7 +67,6 @@
#include <string.h>
using osl::Mutex;
using osl::MutexGuard;
......@@ -108,47 +107,39 @@ namespace pq_sdbc_driver
{
static ::cppu::IPropertyArrayHelper & getStatementPropertyArrayHelper()
{
static ::cppu::IPropertyArrayHelper *pArrayHelper;
if( ! pArrayHelper )
{
MutexGuard guard( Mutex::getGlobalMutex() );
if( ! pArrayHelper )
{
static Property aTable[] =
{
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxFieldSize", 4,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxRows", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"QueryTimeOut", 6,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetConcurrency", 7,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 8,
::cppu::UnoType<sal_Int32>::get() , 0 )
};
static_assert( SAL_N_ELEMENTS(aTable) == STATEMENT_SIZE, "wrong number of elements" );
static ::cppu::OPropertyArrayHelper arrayHelper( aTable, STATEMENT_SIZE, true );
pArrayHelper = &arrayHelper;
}
}
static ::cppu::OPropertyArrayHelper arrayHelper(
Sequence<Property>{
Property(
"CursorName", 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
"EscapeProcessing", 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
"FetchDirection", 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"FetchSize", 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxFieldSize", 4,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"MaxRows", 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"QueryTimeOut", 6,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetConcurrency", 7,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
"ResultSetType", 8,
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
static ::cppu::IPropertyArrayHelper *pArrayHelper = &arrayHelper;
return *pArrayHelper;
}
......@@ -194,20 +185,12 @@ Any Statement::queryInterface( const Type & rType )
Sequence< Type > Statement::getTypes()
{
static Sequence< Type > *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
Statement_BASE::getTypes()));
pCollection = &collection;
}
}
return *pCollection;
static Sequence< Type > collection(
::comphelper::concatSequences(
OPropertySetHelper::getTypes(),
Statement_BASE::getTypes()));
return collection;
}
Sequence< sal_Int8> Statement::getImplementationId()
......
......@@ -147,20 +147,12 @@ css::uno::Any UpdateableResultSet::queryInterface(
css::uno::Sequence< css::uno::Type > UpdateableResultSet::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<XResultSetUpdate>::get(),
cppu::UnoType<XRowUpdate>::get(),
SequenceResultSet::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<XResultSetUpdate>::get(),
cppu::UnoType<XRowUpdate>::get(),
SequenceResultSet::getTypes());
return collection.getTypes();
}
......
......@@ -46,9 +46,6 @@
#include "pq_tools.hxx"
#include "pq_statics.hxx"
using osl::MutexGuard;
using osl::Mutex;
using com::sun::star::container::XNameAccess;
using com::sun::star::uno::Reference;
......@@ -103,19 +100,11 @@ Reference< XNameAccess > Index::getColumns( )
Sequence<Type > Index::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> Index::getImplementationId()
......@@ -175,19 +164,11 @@ Reference< XNameAccess > IndexDescriptor::getColumns( )
Sequence<Type > IndexDescriptor::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> IndexDescriptor::getImplementationId()
......
......@@ -46,9 +46,6 @@
#include "pq_tools.hxx"
#include "pq_statics.hxx"
using osl::MutexGuard;
using osl::Mutex;
using com::sun::star::container::XNameAccess;
using com::sun::star::uno::Reference;
......@@ -105,19 +102,11 @@ Reference< XNameAccess > Key::getColumns( )
Sequence<Type > Key::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> Key::getImplementationId()
......@@ -172,19 +161,11 @@ Reference< XNameAccess > KeyDescriptor::getColumns( )
Sequence<Type > KeyDescriptor::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> KeyDescriptor::getImplementationId()
......
......@@ -263,23 +263,15 @@ void Table::alterColumnByIndex(
Sequence<Type > Table::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XIndexesSupplier>::get(),
cppu::UnoType<css::sdbcx::XKeysSupplier>::get(),
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
cppu::UnoType<css::sdbcx::XRename>::get(),
cppu::UnoType<css::sdbcx::XAlterTable>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XIndexesSupplier>::get(),
cppu::UnoType<css::sdbcx::XKeysSupplier>::get(),
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
cppu::UnoType<css::sdbcx::XRename>::get(),
cppu::UnoType<css::sdbcx::XAlterTable>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> Table::getImplementationId()
......@@ -368,21 +360,13 @@ Reference< XIndexAccess > TableDescriptor::getKeys( )
Sequence<Type > TableDescriptor::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XIndexesSupplier>::get(),
cppu::UnoType<css::sdbcx::XKeysSupplier>::get(),
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XIndexesSupplier>::get(),
cppu::UnoType<css::sdbcx::XKeysSupplier>::get(),
cppu::UnoType<css::sdbcx::XColumnsSupplier>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> TableDescriptor::getImplementationId()
......
......@@ -46,9 +46,6 @@
#include "pq_tools.hxx"
#include "pq_statics.hxx"
using osl::MutexGuard;
using osl::Mutex;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
......@@ -86,19 +83,11 @@ Reference< XPropertySet > User::createDataDescriptor( )
Sequence<Type > User::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XUser>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XUser>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> User::getImplementationId()
......
......@@ -48,7 +48,6 @@
#include "pq_tools.hxx"
using osl::MutexGuard;
using osl::Mutex;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
......@@ -156,19 +155,11 @@ void View::rename( const OUString& newName )
Sequence<Type > View::getTypes()
{
static cppu::OTypeCollection *pCollection;
if( ! pCollection )
{
MutexGuard guard( osl::Mutex::getGlobalMutex() );
if( !pCollection )
{
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XRename>::get(),
ReflectionBase::getTypes());
pCollection = &collection;
}
}
return pCollection->getTypes();
static cppu::OTypeCollection collection(
cppu::UnoType<css::sdbcx::XRename>::get(),
ReflectionBase::getTypes());
return collection.getTypes();
}
Sequence< sal_Int8> View::getImplementationId()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment