dbaccess/source/ui/dlg/sqlmessage.cxx | 57 +++++----------------------------- 1 file changed, 10 insertions(+), 47 deletions(-)
New commits: commit 3556abfe3e2e4d4f8e9d0ea1004427c28851234b Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 20 14:41:18 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 21 02:33:13 2026 +0100 dbaccess: Get SQL exception image name on demand Instead of setting ExceptionDisplayInfo::sImage in multiple code paths depending on the exception type, drop the member and get the image name when actually needed. Change-Id: I684b7c5c63861949367e5a19989376a411fdf423 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199862 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index e65bc2cc4fd9..da89d5f94fea 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -120,7 +120,6 @@ struct ExceptionDisplayInfo { SQLExceptionInfo::TYPE eType; - OUString sImage; std::shared_ptr<LabelProvider> pLabelProvider; bool bSubEntry; @@ -198,7 +197,6 @@ void lcl_buildExceptionChain(const SQLExceptionInfo& _rErrorInfo, const Provider continue; } - aDisplayInfo.sImage = lcl_getImageName(aCurrentElement.getType()); aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider(aCurrentElement.getType(), false); _out_rChain.push_back(std::move(aDisplayInfo)); @@ -211,7 +209,6 @@ void lcl_buildExceptionChain(const SQLExceptionInfo& _rErrorInfo, const Provider ExceptionDisplayInfo aSubInfo(aCurrentElement.getType()); aSubInfo.sMessage = pContext->Details; - aSubInfo.sImage = lcl_getImageName(aCurrentElement.getType()); aSubInfo.pLabelProvider = _rFactory.getLabelProvider(aCurrentElement.getType(), true); aSubInfo.bSubEntry = true; @@ -281,7 +278,6 @@ OExceptionChainDialog::OExceptionChainDialog(weld::Window* pParent, ExceptionDis ExceptionDisplayInfo aInfo22018; aInfo22018.sMessage = DBA_RES( STR_EXPLAN_STRINGCONVERSION_ERROR ); aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::TYPE::SQLContext, false ); - aInfo22018.sImage = lcl_getImageName(SQLExceptionInfo::TYPE::SQLContext); m_aExceptions.push_back( aInfo22018 ); insertExceptionEntry(m_aExceptions.size() - 1, aInfo22018); @@ -298,7 +294,7 @@ void OExceptionChainDialog::insertExceptionEntry(size_t nElementPos, const ExceptionDisplayInfo& rEntry) { m_xExceptionList->append(OUString::number(nElementPos), rEntry.pLabelProvider->getLabel(), - rEntry.sImage); + lcl_getImageName(rEntry.eType)); } IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, weld::TreeView&, void) commit 04e20148c66a14d0128747700a906069128e7a5e Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 20 14:28:22 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 21 02:33:06 2026 +0100 dbaccess: Get rid of ImageProvider complexity The ImageProvider only has an OUString for an image name. Drop the complexity and simply use the image name string directly in ExceptionDisplayInfo. Sample scenario where the code is used is by the dialog that can be triggered like this (seen on Debian testing): * start Writer * enable "View" -> "Toolbars" -> "Mail Merge" * press the "Address Book Source" toolbar button * press the "Assign" button in the dialog * in the "Address Book Data Source Wizard" dialog that shows up, select "Thunderbird" and press "Next" button * in the dialog showing an error message that shows up, press the "More" button Change-Id: I243d7a80f0b6251b01969c243d2a45af4a97ec09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199861 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 48ee9875fa83..e65bc2cc4fd9 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -51,19 +51,18 @@ namespace dbaui namespace { -class ImageProvider +OUString lcl_getImageName(SQLExceptionInfo::TYPE eType) { -private: - OUString m_defaultImageID; - -public: - explicit ImageProvider(OUString defaultImageID) - : m_defaultImageID(std::move(defaultImageID)) + switch (eType) { + case SQLExceptionInfo::TYPE::SQLWarning: + return u"dialog-warning"_ustr; + case SQLExceptionInfo::TYPE::SQLContext: + return u"dialog-information"_ustr; + default: + return u"dialog-error"_ustr; } - - const OUString& getImage() const { return m_defaultImageID; } -}; +} class LabelProvider { @@ -82,9 +81,6 @@ public: class ProviderFactory { private: - mutable std::shared_ptr<ImageProvider> m_pErrorImage; - mutable std::shared_ptr<ImageProvider> m_pWarningsImage; - mutable std::shared_ptr<ImageProvider> m_pInfoImage; mutable std::shared_ptr<LabelProvider> m_pErrorLabel; mutable std::shared_ptr<LabelProvider> m_pWarningsLabel; mutable std::shared_ptr<LabelProvider> m_pInfoLabel; @@ -92,32 +88,6 @@ private: public: ProviderFactory() {} - std::shared_ptr<ImageProvider> const& getImageProvider(SQLExceptionInfo::TYPE _eType) const - { - std::shared_ptr<ImageProvider>* ppProvider(&m_pErrorImage); - OUString sNormalImageID(u"dialog-error"_ustr); - - switch (_eType) - { - case SQLExceptionInfo::TYPE::SQLWarning: - ppProvider = &m_pWarningsImage; - sNormalImageID = "dialog-warning"; - break; - - case SQLExceptionInfo::TYPE::SQLContext: - ppProvider = &m_pInfoImage; - sNormalImageID = "dialog-information"; - break; - - default: - break; - } - - if (!ppProvider->get()) - (*ppProvider) = std::make_shared<ImageProvider>(sNormalImageID); - return *ppProvider; - } - std::shared_ptr<LabelProvider> const& getLabelProvider(SQLExceptionInfo::TYPE _eType, bool _bSubLabel) const { @@ -150,7 +120,7 @@ struct ExceptionDisplayInfo { SQLExceptionInfo::TYPE eType; - std::shared_ptr<ImageProvider> pImageProvider; + OUString sImage; std::shared_ptr<LabelProvider> pLabelProvider; bool bSubEntry; @@ -228,7 +198,7 @@ void lcl_buildExceptionChain(const SQLExceptionInfo& _rErrorInfo, const Provider continue; } - aDisplayInfo.pImageProvider = _rFactory.getImageProvider(aCurrentElement.getType()); + aDisplayInfo.sImage = lcl_getImageName(aCurrentElement.getType()); aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider(aCurrentElement.getType(), false); _out_rChain.push_back(std::move(aDisplayInfo)); @@ -241,7 +211,7 @@ void lcl_buildExceptionChain(const SQLExceptionInfo& _rErrorInfo, const Provider ExceptionDisplayInfo aSubInfo(aCurrentElement.getType()); aSubInfo.sMessage = pContext->Details; - aSubInfo.pImageProvider = _rFactory.getImageProvider(aCurrentElement.getType()); + aSubInfo.sImage = lcl_getImageName(aCurrentElement.getType()); aSubInfo.pLabelProvider = _rFactory.getLabelProvider(aCurrentElement.getType(), true); aSubInfo.bSubEntry = true; @@ -311,7 +281,7 @@ OExceptionChainDialog::OExceptionChainDialog(weld::Window* pParent, ExceptionDis ExceptionDisplayInfo aInfo22018; aInfo22018.sMessage = DBA_RES( STR_EXPLAN_STRINGCONVERSION_ERROR ); aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::TYPE::SQLContext, false ); - aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::TYPE::SQLContext ); + aInfo22018.sImage = lcl_getImageName(SQLExceptionInfo::TYPE::SQLContext); m_aExceptions.push_back( aInfo22018 ); insertExceptionEntry(m_aExceptions.size() - 1, aInfo22018); @@ -328,7 +298,7 @@ void OExceptionChainDialog::insertExceptionEntry(size_t nElementPos, const ExceptionDisplayInfo& rEntry) { m_xExceptionList->append(OUString::number(nElementPos), rEntry.pLabelProvider->getLabel(), - rEntry.pImageProvider->getImage()); + rEntry.sImage); } IMPL_LINK_NOARG(OExceptionChainDialog, OnExceptionSelected, weld::TreeView&, void) commit 078196312f3cb8ff681648c4898c15e2f73000fd Author: Michael Weghorn <[email protected]> AuthorDate: Fri Feb 20 14:19:50 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Feb 21 02:32:59 2026 +0100 dbaccess: Merge 2 anonymous namespaces in sqlmessage.cxx Change-Id: I59b8df1c03b3a79a1d60b836b49d953190172375 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199860 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index 29bb20cd75bb..48ee9875fa83 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -251,9 +251,6 @@ void lcl_buildExceptionChain(const SQLExceptionInfo& _rErrorInfo, const Provider } } } -} - -namespace { class OExceptionChainDialog : public weld::GenericDialogController {
