sw/source/ui/dbui/mmgreetingspage.cxx |    4 ++--
 sw/source/ui/dbui/mmgreetingspage.hxx |    3 ++-
 sw/source/ui/dbui/mmresultdialogs.cxx |   17 +++++++----------
 sw/source/uibase/utlui/content.cxx    |    5 ++---
 4 files changed, 13 insertions(+), 16 deletions(-)

New commits:
commit b9f9493b43f89ad1560e9779796ade7854aa2b74
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu May 23 11:07:20 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu May 23 15:52:52 2024 +0200

    sw: warning C6011: Dereferencing NULL pointer
    
    Change-Id: I612ec139354345f48fb5d3b41bdb10c37ad85ff7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167983
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx 
b/sw/source/ui/dbui/mmgreetingspage.cxx
index 5fb6ed5a0648..3e5f8d43c243 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -337,9 +337,9 @@ IMPL_LINK(SwMailMergeGreetingsPage, InsertDataHdl_Impl, 
weld::Button&, rButton,
     m_xDocumentIndexFI->set_label(m_sDocument.replaceFirst("%1", 
OUString::number(nPos)));
 }
 
-SwMailBodyDialog::SwMailBodyDialog(weld::Window* pParent)
+SwMailBodyDialog::SwMailBodyDialog(weld::Window* pParent, 
std::shared_ptr<SwMailMergeConfigItem> const & rConfigItem)
     : SfxDialogController(pParent, u"modules/swriter/ui/mmmailbody.ui"_ustr, 
u"MailBodyDialog"_ustr)
-    , SwGreetingsHandler(*GetActiveView()->GetMailMergeConfigItem(), 
*m_xBuilder)
+    , SwGreetingsHandler(*rConfigItem, *m_xBuilder)
     , m_xBodyMLE(m_xBuilder->weld_text_view(u"bodymle"_ustr))
     , m_xOK(m_xBuilder->weld_button(u"ok"_ustr))
 {
diff --git a/sw/source/ui/dbui/mmgreetingspage.hxx 
b/sw/source/ui/dbui/mmgreetingspage.hxx
index 7d266870b13b..39761659bdcc 100644
--- a/sw/source/ui/dbui/mmgreetingspage.hxx
+++ b/sw/source/ui/dbui/mmgreetingspage.hxx
@@ -119,7 +119,8 @@ class SwMailBodyDialog : public SfxDialogController, public 
SwGreetingsHandler
     DECL_LINK(OKHdl, weld::Button&, void);
 
 public:
-    SwMailBodyDialog(weld::Window* pParent);
+    SwMailBodyDialog(weld::Window* pParent,
+                     std::shared_ptr<SwMailMergeConfigItem> const& 
rConfigItem);
     virtual ~SwMailBodyDialog() override;
 
     void SetBody(const OUString& rBody) { m_xBodyMLE->set_text(rBody); }
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx 
b/sw/source/ui/dbui/mmresultdialogs.cxx
index e36306678c8f..35ea44e6e5b4 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -892,17 +892,14 @@ IMPL_LINK(SwMMResultEmailDialog, SendTypeHdl_Impl, 
weld::ComboBox&, rBox, void)
 
 IMPL_LINK_NOARG(SwMMResultEmailDialog, SendAsHdl_Impl, weld::Button&, void)
 {
-    // work around crash when calling constructor with no active view
-    if (!GetActiveView())
-    {
-        SAL_WARN("sw", "ignoring SendAs button click, because no active view");
-        return;
-    }
-    SwMailBodyDialog aDlg(m_xDialog.get());
-    aDlg.SetBody(m_sBody);
-    if (RET_OK == aDlg.run())
+    if (SwView* pView = GetActiveView())
     {
-        m_sBody = aDlg.GetBody();
+        SwMailBodyDialog aDlg(m_xDialog.get(), 
pView->GetMailMergeConfigItem());
+        aDlg.SetBody(m_sBody);
+        if (RET_OK == aDlg.run())
+        {
+            m_sBody = aDlg.GetBody();
+        }
     }
 }
 
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index fb7833e244a4..1346d3bb5094 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -3156,9 +3156,8 @@ bool 
SwContentTree::FillTransferData(TransferDataContainer& rTransfer)
                 SfxMedium* pMedium = pDocShell->GetMedium();
                 sUrl = pMedium->GetURLObject().GetURLNoMark();
             }
-            else if (State::CONSTANT == m_eState
-                     && (!::GetActiveView()
-                         || m_pActiveShell != 
::GetActiveView()->GetWrtShellPtr()))
+            else if (SwView* pView = GetActiveView(); State::CONSTANT == 
m_eState
+                     && (!pView || m_pActiveShell != pView->GetWrtShellPtr()))
             {
                 // Urls of inactive views cannot dragged without
                 // file names, also.

Reply via email to