canvas/inc/base/spritecanvasbase.hxx | 10 +++++---- canvas/source/cairo/cairo_canvashelper.cxx | 2 - canvas/source/directx/dx_canvashelper_texturefill.cxx | 7 ++++-- canvas/source/opengl/ogl_canvashelper.cxx | 3 +- chart2/source/controller/accessibility/AccessibleBase.cxx | 2 - chart2/source/controller/accessibility/AccessibleChartElement.cxx | 3 +- chart2/source/controller/accessibility/AccessibleChartShape.cxx | 3 +- chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx | 8 +++---- chart2/source/controller/chartapiwrapper/TitleWrapper.cxx | 11 ++++++---- 9 files changed, 30 insertions(+), 19 deletions(-)
New commits: commit f87ed54e469ff17a48c7aefdfe665c2c9631b30f Author: Chiggy Wiggy <[email protected]> AuthorDate: Sat Dec 6 06:12:48 2025 +0100 Commit: Hossein <[email protected]> CommitDate: Tue Dec 23 10:44:20 2025 +0100 tdf#43157 canvas & chart2 : Replace OSL_ASSERT with SAL_WARN_IF Replace obsolete OSL_ASSERT usages with SAL_WARN_IF inside the canvas module. This ensures debug warnings are logged without aborting execution. Change-Id: Idad9b3a7c250e45903b40cc2a82c43f8fead2bc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195142 Reviewed-by: Hossein <[email protected]> Tested-by: Jenkins diff --git a/canvas/inc/base/spritecanvasbase.hxx b/canvas/inc/base/spritecanvasbase.hxx index 0af4f913851e..b62b0bc3437a 100644 --- a/canvas/inc/base/spritecanvasbase.hxx +++ b/canvas/inc/base/spritecanvasbase.hxx @@ -23,6 +23,7 @@ #include <com/sun/star/rendering/InterpolationMode.hpp> #include <base/integerbitmapbase.hxx> #include <base/bitmapcanvasbase.hxx> +#include <sal/log.hxx> #include <spriteredrawmanager.hxx> namespace com::sun::star::rendering { class XAnimation; } @@ -143,7 +144,8 @@ namespace canvas // SpriteSurface virtual void showSprite( const Sprite::Reference& rSprite ) override { - OSL_ASSERT( rSprite.is() ); + SAL_WARN_IF( !rSprite.is(), "canvas", "rSprite is null in showSprite()" ); + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); @@ -152,7 +154,7 @@ namespace canvas virtual void hideSprite( const Sprite::Reference& rSprite ) override { - OSL_ASSERT( rSprite.is() ); + SAL_WARN_IF( !rSprite.is(), "canvas", "rSprite is null in hideSprite()" ); typename BaseType::MutexType aGuard( BaseType::m_aMutex ); @@ -164,7 +166,7 @@ namespace canvas const ::basegfx::B2DPoint& rNewPos, const ::basegfx::B2DVector& rSpriteSize ) override { - OSL_ASSERT( rSprite.is() ); + SAL_WARN_IF( !rSprite.is(), "canvas", "rSprite is null in moveSprite()" ); typename BaseType::MutexType aGuard( BaseType::m_aMutex ); @@ -175,7 +177,7 @@ namespace canvas const ::basegfx::B2DPoint& rPos, const ::basegfx::B2DRange& rUpdateArea ) override { - OSL_ASSERT( rSprite.is() ); + SAL_WARN_IF( !rSprite.is(), "canvas", "rSprite is null in updateSprite()" ); typename BaseType::MutexType aGuard( BaseType::m_aMutex ); diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 7de290538cfb..3285a4fadd1c 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -368,7 +368,7 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas:: { int i; - OSL_ASSERT( rColors.getLength() == rStops.getLength() ); + assert(rColors.getLength() == rStops.getLength() && "Color count does not match stop count"); for( i = 0; i < rColors.getLength(); i++ ) { diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx index 4cf7cec07004..d9f3489997e8 100644 --- a/canvas/source/directx/dx_canvashelper_texturefill.cxx +++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx @@ -18,7 +18,9 @@ */ #include <sal/config.h> +#include <sal/log.hxx> +#include <cassert> #include <cstdlib> #include <memory> #include <tuple> @@ -566,8 +568,9 @@ namespace dxcanvas const ::canvas::ParametricPolyPolygon::Values& rValues( pGradient->getValues() ); - OSL_ASSERT(rValues.maColors.getLength() == rValues.maStops.getLength() - && rValues.maColors.getLength() > 1); + assert( + rValues.maColors.getLength() == rValues.maStops.getLength() && rValues.maColors.getLength() > 1 + && "Gradient colors/stops mismatched"); std::vector< Gdiplus::Color > aColors(rValues.maColors.getLength()); std::transform(&rValues.maColors[0], diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 0b6f0f1c147e..6d7e2aa764e2 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -9,6 +9,7 @@ #include <sal/config.h> +#include <sal/log.hxx> #include <memory> #include <functional> #include <epoxy/gl.h> @@ -173,7 +174,7 @@ namespace oglcanvas for( sal_Int32 i=0; i<nNumCols; ++i ) *pCurrCol++ = rHelper.getDevice()->getDeviceColorSpace()->convertToARGB(rValues.maColors[i])[0]; - OSL_ASSERT(nNumCols == rValues.maStops.getLength()); + SAL_WARN_IF(nNumCols != rValues.maStops.getLength(), "canvas", "Color count does not match stops count"); switch( rValues.meType ) { diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx index a301d6f35499..c22c02055933 100644 --- a/chart2/source/controller/accessibility/AccessibleBase.cxx +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -80,7 +80,7 @@ AccessibleBase::AccessibleBase( AccessibleBase::~AccessibleBase() { - OSL_ASSERT(!isAlive()); + SAL_WARN_IF(isAlive(), "chart2.accessibility", "AccessibleBase destroyed while still alive"); } bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId & rId ) diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx index 57b20f14b12c..1ade6282fa10 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -19,6 +19,7 @@ #include "AccessibleChartElement.hxx" #include <AccessibleTextHelper.hxx> +#include <sal/log.hxx> #include <ChartModel.hxx> #include <ChartController.hxx> #include <ObjectIdentifier.hxx> @@ -47,7 +48,7 @@ AccessibleChartElement::AccessibleChartElement( AccessibleChartElement::~AccessibleChartElement() { - OSL_ASSERT(!isAlive()); + SAL_WARN_IF(isAlive(), "chart2.accessibility", "AccessibleChartElement destroyed while still alive (not disposed)"); } // ________ protected ________ diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx index 9c4b3d531f94..cbebfd8da775 100644 --- a/chart2/source/controller/accessibility/AccessibleChartShape.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx @@ -19,6 +19,7 @@ #include "AccessibleChartShape.hxx" +#include <sal/log.hxx> #include <svx/ShapeTypeHandler.hxx> #include <svx/AccessibleShape.hxx> #include <svx/AccessibleShapeInfo.hxx> @@ -61,7 +62,7 @@ AccessibleChartShape::AccessibleChartShape( AccessibleChartShape::~AccessibleChartShape() { - OSL_ASSERT(!isAlive()); + SAL_WARN_IF(isAlive(), "chart2.accessibility", "AccessibleChartShape destroyed while still alive"); if ( m_pAccShape.is() ) { diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index b2c38d31bde5..948af8281f44 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -26,11 +26,11 @@ #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/chart/XChartDocument.hpp> +#include <sal/log.hxx> #include <float.h> #include <cmath> #include <limits> #include <utility> -#include <osl/diagnose.h> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -572,7 +572,7 @@ void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEven return; uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this )); - OSL_ASSERT( xSrc.is()); + SAL_WARN_IF( !xSrc.is(), "chart2", "Source is null" ); if( xSrc.is() ) aEvent.Source = std::move(xSrc); @@ -622,7 +622,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) bool bPercent = false; bool bDeep = false; uno::Reference< css::chart::XChartDocument > xOldDoc( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); - OSL_ASSERT( xOldDoc.is()); + SAL_WARN_IF( !xOldDoc.is(), "chart2", "Could not query XChartDocument" ); uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY ); if( xDiaProp.is()) { @@ -656,7 +656,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) switchToInternalDataProvider(); rDataOperator.apply(m_xDataAccess); uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); - OSL_ASSERT( xDataProvider.is() ); + SAL_WARN_IF( !xDataProvider.is(), "chart2", "DataProvider is null" ); if( !xDataProvider.is() ) return; uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index e4ca74c37f19..6044f64eb5a5 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -37,6 +37,7 @@ #include "WrappedScaleTextProperties.hxx" #include <algorithm> +#include <sal/log.hxx> #include <rtl/ustrbuf.hxx> #include <cppuhelper/propshlp.hxx> #include <utility> @@ -315,8 +316,9 @@ void SAL_CALL TitleWrapper::removeEventListener( void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue ) { - OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && - nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); + SAL_WARN_IF( nHandle < FAST_PROPERTY_ID_START_CHAR_PROP || + nHandle >= CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP, + "chart2", "Handle out of range" ); Reference< beans::XPropertySet > xProp = getInnerPropertySet(); Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); @@ -338,8 +340,9 @@ void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue void TitleWrapper::setFastCharacterPropertyValue( sal_Int32 nHandle, const Any& rValue ) { - OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && - nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); + SAL_WARN_IF( nHandle < FAST_PROPERTY_ID_START_CHAR_PROP || + nHandle >= CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP, + "chart2", "Handle out of range" ); Reference< chart2::XTitle > xTitle( getTitleObject() ); if( !xTitle.is())
