dbaccess/source/core/api/preparedstatement.cxx |    5 +++--
 dbaccess/source/core/api/statement.cxx         |   20 +++++++++++---------
 dbaccess/source/core/dataaccess/connection.cxx |    2 +-
 dbaccess/source/core/dataaccess/datasource.cxx |    2 +-
 dbaccess/source/core/inc/callablestatement.hxx |    2 +-
 dbaccess/source/core/inc/connection.hxx        |    8 ++++----
 dbaccess/source/core/inc/preparedstatement.hxx |    2 +-
 dbaccess/source/core/inc/statement.hxx         |   11 +++++++----
 include/vcl/BitmapAlphaClampFilter.hxx         |    3 +--
 solenv/clang-format/excludelist                |    2 +-
 vcl/qa/cppunit/BitmapFilterTest.cxx            |   19 +++++++++++++++++++
 11 files changed, 50 insertions(+), 26 deletions(-)

New commits:
commit f7354e18731ae41ab86584b04b0b23bee844f3dd
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Sep 17 14:29:32 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Sep 18 08:06:47 2024 +0200

    remove OSubComponent from OStatementBase
    
    which attempts to implement a very dodgy and almost but not actually
    thread-safe dispose function. Rather just hold a weak reference to the
    connection that created us.
    
    Change-Id: I01e4f5fc0a8aeb33adc14a2981ce09522a0306bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173572
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/core/api/preparedstatement.cxx 
b/dbaccess/source/core/api/preparedstatement.cxx
index 3691477a5ebd..ecb1a4c1e348 100644
--- a/dbaccess/source/core/api/preparedstatement.cxx
+++ b/dbaccess/source/core/api/preparedstatement.cxx
@@ -31,6 +31,7 @@
 #include <strings.hxx>
 #include "resultcolumn.hxx"
 #include "resultset.hxx"
+#include <connection.hxx>
 #include <comphelper/diagnose_ex.hxx>
 
 using namespace ::com::sun::star::sdbc;
@@ -42,7 +43,7 @@ using namespace ::osl;
 using namespace dbaccess;
 
 
-OPreparedStatement::OPreparedStatement(const Reference< XConnection > & _xConn,
+OPreparedStatement::OPreparedStatement(const rtl::Reference< OConnection > & 
_xConn,
                                       const Reference< XInterface > & 
_xStatement)
                    :OStatementBase(_xConn, _xStatement)
 {
@@ -220,7 +221,7 @@ sal_Bool OPreparedStatement::execute()
 
 Reference< XConnection > OPreparedStatement::getConnection()
 {
-    return Reference< XConnection > (m_xParent, UNO_QUERY);
+    return m_xParent.get();
 }
 
 // XParameters
diff --git a/dbaccess/source/core/api/statement.cxx 
b/dbaccess/source/core/api/statement.cxx
index 3a6dfe2a490e..7166de42a233 100644
--- a/dbaccess/source/core/api/statement.cxx
+++ b/dbaccess/source/core/api/statement.cxx
@@ -31,6 +31,7 @@
 #include <comphelper/types.hxx>
 #include <comphelper/diagnose_ex.hxx>
 #include <connectivity/dbexception.hxx>
+#include <connection.hxx>
 
 using namespace ::com::sun::star::sdb;
 using namespace ::com::sun::star::sdbc;
@@ -43,10 +44,11 @@ using namespace dbaccess;
 using namespace dbtools;
 
 
-OStatementBase::OStatementBase(const Reference< XConnection > & _xConn,
+OStatementBase::OStatementBase(const rtl::Reference< OConnection > & _xConn,
                                const Reference< XInterface > & _xStatement)
-    :OSubComponent(m_aMutex, _xConn)
+    :WeakComponentImplHelper(m_aMutex)
     ,OPropertySetHelper(WeakComponentImplHelper::rBHelper)
+    ,m_xParent(_xConn.get())
     ,m_bUseBookmarks( false )
     ,m_bEscapeProcessing( true )
 
@@ -68,7 +70,7 @@ Sequence< Type > OStatementBase::getTypes()
                            cppu::UnoType<XCloseable>::get(),
                            cppu::UnoType<XMultipleResults>::get(),
                            cppu::UnoType<css::util::XCancellable>::get(),
-                           OSubComponent::getTypes() );
+                           ::cppu::WeakComponentImplHelper<>::getTypes() );
     Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
     if ( xGRes.is() )
         aTypes = 
OTypeCollection(cppu::UnoType<XGeneratedResultSet>::get(),aTypes.getTypes());
@@ -82,7 +84,7 @@ Sequence< Type > OStatementBase::getTypes()
 // css::uno::XInterface
 Any OStatementBase::queryInterface( const Type & rType )
 {
-    Any aIface = OSubComponent::queryInterface( rType );
+    Any aIface = ::cppu::WeakComponentImplHelper<>::queryInterface( rType );
     if (!aIface.hasValue())
     {
         aIface = ::cppu::queryInterface(
@@ -110,12 +112,12 @@ Any OStatementBase::queryInterface( const Type & rType )
 
 void OStatementBase::acquire() noexcept
 {
-    OSubComponent::acquire();
+    ::cppu::WeakComponentImplHelper<>::acquire();
 }
 
 void OStatementBase::release() noexcept
 {
-    OSubComponent::release();
+    ::cppu::WeakComponentImplHelper<>::release();
 }
 
 void OStatementBase::disposeResultSet()
@@ -159,7 +161,7 @@ void OStatementBase::disposing()
     m_xAggregateAsSet = nullptr;
 
     // free the parent at last
-    OSubComponent::disposing();
+    ::cppu::WeakComponentImplHelper<>::disposing();
 }
 
 // XCloseable
@@ -419,7 +421,7 @@ Reference< XResultSet > SAL_CALL 
OStatementBase::getGeneratedValues(  )
 
 //  OStatement
 
-OStatement::OStatement( const Reference< XConnection >& _xConn, const 
Reference< XInterface > & _xStatement )
+OStatement::OStatement( const rtl::Reference< OConnection >& _xConn, const 
Reference< XInterface > & _xStatement )
     :OStatementBase( _xConn, _xStatement )
     ,m_bAttemptedComposerCreation( false )
 {
@@ -534,7 +536,7 @@ Sequence< sal_Int32 > OStatement::executeBatch( )
 
 Reference< XConnection > OStatement::getConnection()
 {
-    return Reference< XConnection >( m_xParent, UNO_QUERY );
+    return m_xParent.get();
 }
 
 void SAL_CALL OStatement::disposing()
diff --git a/dbaccess/source/core/dataaccess/connection.cxx 
b/dbaccess/source/core/dataaccess/connection.cxx
index 2281226f8d7e..982303889a82 100644
--- a/dbaccess/source/core/dataaccess/connection.cxx
+++ b/dbaccess/source/core/dataaccess/connection.cxx
@@ -21,7 +21,7 @@
 
 #include <iterator>
 
-#include "connection.hxx"
+#include <connection.hxx>
 #include "datasource.hxx"
 #include <strings.hrc>
 #include <strings.hxx>
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx 
b/dbaccess/source/core/dataaccess/datasource.cxx
index d97ede01612a..f8874911b960 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -23,7 +23,7 @@
 #include <core_resource.hxx>
 #include <strings.hrc>
 #include <strings.hxx>
-#include "connection.hxx"
+#include <connection.hxx>
 #include "SharedConnection.hxx"
 #include "databasedocument.hxx"
 #include <OAuthenticationContinuation.hxx>
diff --git a/dbaccess/source/core/inc/callablestatement.hxx 
b/dbaccess/source/core/inc/callablestatement.hxx
index 58e21189aa59..c5d7b94154d9 100644
--- a/dbaccess/source/core/inc/callablestatement.hxx
+++ b/dbaccess/source/core/inc/callablestatement.hxx
@@ -32,7 +32,7 @@ namespace dbaccess
                                public css::sdbc::XOutParameters
     {
     public:
-        OCallableStatement(const css::uno::Reference< css::sdbc::XConnection > 
& _xConn,
+        OCallableStatement(const rtl::Reference< OConnection > & _xConn,
                            const css::uno::Reference< css::uno::XInterface > & 
_xStatement)
             :OPreparedStatement(_xConn, _xStatement){}
 
diff --git a/dbaccess/source/core/dataaccess/connection.hxx 
b/dbaccess/source/core/inc/connection.hxx
similarity index 98%
rename from dbaccess/source/core/dataaccess/connection.hxx
rename to dbaccess/source/core/inc/connection.hxx
index 4c1790207163..60d966ab64c5 100644
--- a/dbaccess/source/core/dataaccess/connection.hxx
+++ b/dbaccess/source/core/inc/connection.hxx
@@ -24,10 +24,10 @@
 #include <cstddef>
 #include <map>
 
-#include <querycontainer.hxx>
-#include <tablecontainer.hxx>
-#include <viewcontainer.hxx>
-#include <RefreshListener.hxx>
+#include "querycontainer.hxx"
+#include "tablecontainer.hxx"
+#include "viewcontainer.hxx"
+#include "RefreshListener.hxx"
 
 #include <com/sun/star/container/XChild.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
diff --git a/dbaccess/source/core/inc/preparedstatement.hxx 
b/dbaccess/source/core/inc/preparedstatement.hxx
index cea06d79a81e..d39af31e13cb 100644
--- a/dbaccess/source/core/inc/preparedstatement.hxx
+++ b/dbaccess/source/core/inc/preparedstatement.hxx
@@ -42,7 +42,7 @@ namespace dbaccess
         css::uno::Reference< css::sdbc::XParameters > m_xAggregateAsParameters;
 
     public:
-        OPreparedStatement(const css::uno::Reference< css::sdbc::XConnection > 
& _xConn,
+        OPreparedStatement(const rtl::Reference< OConnection > & _xConn,
                            const css::uno::Reference< css::uno::XInterface > & 
_xStatement);
         virtual ~OPreparedStatement() override;
 
diff --git a/dbaccess/source/core/inc/statement.hxx 
b/dbaccess/source/core/inc/statement.hxx
index f437040682fb..3ab67085164f 100644
--- a/dbaccess/source/core/inc/statement.hxx
+++ b/dbaccess/source/core/inc/statement.hxx
@@ -33,13 +33,15 @@
 #include <comphelper/proparrhlp.hxx>
 #include <cppuhelper/basemutex.hxx>
 #include <cppuhelper/implbase3.hxx>
-#include <apitools.hxx>
+#include <cppuhelper/compbase.hxx>
+#include <unotools/weakref.hxx>
 
+namespace dbaccess { class OConnection; }
 
 //  OStatementBase
 
 class OStatementBase :  public cppu::BaseMutex,
-                        public OSubComponent,
+                        public ::cppu::WeakComponentImplHelper<>,
                         public ::cppu::OPropertySetHelper,
                         public ::comphelper::OPropertyArrayUsageHelper < 
OStatementBase >,
                         public css::util::XCancellable,
@@ -50,6 +52,7 @@ class OStatementBase :  public cppu::BaseMutex,
                         public css::sdbc::XGeneratedResultSet
 {
 protected:
+    unotools::WeakReference<::dbaccess::OConnection> m_xParent;
     ::osl::Mutex            m_aCancelMutex;
 
     css::uno::WeakReferenceHelper                   m_aResultSet;
@@ -61,7 +64,7 @@ protected:
     virtual ~OStatementBase() override;
 
 public:
-    OStatementBase(const css::uno::Reference< css::sdbc::XConnection > & 
_xConn,
+    OStatementBase(const rtl::Reference< ::dbaccess::OConnection > & _xConn,
                    const css::uno::Reference< css::uno::XInterface > & 
_xStatement);
 
 
@@ -141,7 +144,7 @@ private:
     bool                                                          
m_bAttemptedComposerCreation;
 
 public:
-    OStatement(const css::uno::Reference< css::sdbc::XConnection > & _xConn,
+    OStatement(const rtl::Reference< ::dbaccess::OConnection > & _xConn,
                const css::uno::Reference< css::uno::XInterface > & 
_xStatement);
 
     DECLARE_XINTERFACE()
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index ab1aa49b892c..9075a86e174f 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -2603,7 +2603,6 @@ dbaccess/source/core/dataaccess/commandcontainer.hxx
 dbaccess/source/core/dataaccess/commanddefinition.cxx
 dbaccess/source/core/dataaccess/commanddefinition.hxx
 dbaccess/source/core/dataaccess/connection.cxx
-dbaccess/source/core/dataaccess/connection.hxx
 dbaccess/source/core/dataaccess/dataaccessdescriptor.cxx
 dbaccess/source/core/dataaccess/databasecontext.cxx
 dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -2642,6 +2641,7 @@ dbaccess/source/core/inc/column.hxx
 dbaccess/source/core/inc/columnsettings.hxx
 dbaccess/source/core/inc/commandbase.hxx
 dbaccess/source/core/inc/composertools.hxx
+dbaccess/source/core/inc/connection.hxx
 dbaccess/source/core/inc/containerapprove.hxx
 dbaccess/source/core/inc/databasecontext.hxx
 dbaccess/source/core/inc/datasettings.hxx
commit 05c01410f3c0fcb791f60b19ce2085beee1dabe0
Author:     Chris Sherlock <[email protected]>
AuthorDate: Sat Sep 14 01:04:55 2024 +1000
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Sep 18 08:06:33 2024 +0200

    vcl: test BitmapAlphaClampFilter
    
    Change-Id: Ie44884a3010cd26b057bac593059a4bd0a3aabc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173345
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/include/vcl/BitmapAlphaClampFilter.hxx 
b/include/vcl/BitmapAlphaClampFilter.hxx
index 8ff8a8d91867..21163862af4c 100644
--- a/include/vcl/BitmapAlphaClampFilter.hxx
+++ b/include/vcl/BitmapAlphaClampFilter.hxx
@@ -10,12 +10,11 @@
 
 #pragma once
 
-#include <config_options.h>
 #include <vcl/BitmapFilter.hxx>
 
 /** If the alpha is beyond a certain threshold, make it fully transparent
  */
-class UNLESS_MERGELIBS(VCL_DLLPUBLIC) BitmapAlphaClampFilter final : public 
BitmapFilter
+class VCL_DLLPUBLIC BitmapAlphaClampFilter final : public BitmapFilter
 {
 public:
     BitmapAlphaClampFilter(sal_uInt8 cThreshold)
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx 
b/vcl/qa/cppunit/BitmapFilterTest.cxx
index e492b963f48d..099720a1569d 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -15,6 +15,7 @@
 #include <tools/stream.hxx>
 #include <vcl/graphicfilter.hxx>
 
+#include <vcl/BitmapAlphaClampFilter.hxx>
 #include <vcl/BitmapArithmeticBlendFilter.hxx>
 #include <vcl/BitmapDarkenBlendFilter.hxx>
 #include <vcl/BitmapLightenBlendFilter.hxx>
@@ -41,6 +42,7 @@ public:
     {
     }
 
+    void testClampAlpha();
     void testBlurCorrectness();
     void testBasicMorphology();
     void testPerformance();
@@ -53,6 +55,7 @@ public:
     void testArithmeticBlendFilter();
 
     CPPUNIT_TEST_SUITE(BitmapFilterTest);
+    CPPUNIT_TEST(testClampAlpha);
     CPPUNIT_TEST(testBlurCorrectness);
     CPPUNIT_TEST(testBasicMorphology);
     CPPUNIT_TEST(testPerformance);
@@ -91,6 +94,22 @@ private:
     }
 };
 
+void BitmapFilterTest::testClampAlpha()
+{
+    // Setup test bitmap
+    Size aSize(1, 1);
+    Bitmap aBitmap24Bit(aSize, vcl::PixelFormat::N24_BPP);
+
+    {
+        BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
+        aWriteAccess->Erase(COL_RED);
+    }
+
+    BitmapEx aBitmapEx24Bit(aBitmap24Bit);
+    BitmapFilter::Filter(aBitmapEx24Bit, BitmapAlphaClampFilter(0x7F));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(0xFF), 
aBitmapEx24Bit.GetAlpha(0, 0));
+}
+
 void BitmapFilterTest::testBlurCorrectness()
 {
     // Setup test bitmap

Reply via email to