diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-02-16 12:38:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-02-17 16:03:11 +0000 |
commit | 25b38765d6e500af196ce312a3e1d819c6a7d09c (patch) | |
tree | 2ebeaa7c9870b18876752bbb316a491e78e0682a /sw/source/ui/fldui | |
parent | 08b0443e0f50f79ee26fad4eada0190623b9b30a (diff) |
check GetActiveWrtShell() and CheckAndGetWrtShell()
See https://crashreport.libreoffice.org/stats/signature/SwModule::ApplyItemSet(unsigned%20short,SfxItemSet%20const%20&)
Change-Id: I7c719c5fe4cda9f6571592c30f39bd440053dbe9
Change-Id: Iaa4448dccd1a0ec1aefa539e476b5046ed50f7b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147155
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui/fldui')
-rw-r--r-- | sw/source/ui/fldui/flddb.cxx | 25 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldfunc.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 17 |
3 files changed, 22 insertions, 22 deletions
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 3293a6bc670d..62dd538f01e0 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -73,7 +73,7 @@ SwFieldDBPage::SwFieldDBPage(weld::Container* pPage, weld::DialogController* pCo SwFieldDBPage::~SwFieldDBPage() { // If we have no stored SwWrtShell, it means we didn't do anything useful - no need to revoke. - if (SwWrtShell* pSh = GetWrtShell()) + if (SwWrtShell* pSh = CheckAndGetWrtShell()) { // This would cleanup in the case of cancelled dialog SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager(); @@ -140,8 +140,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*) } else { - SwWrtShell *pSh = CheckAndGetWrtShell(); - if(pSh) + if (SwWrtShell *pSh = CheckAndGetWrtShell()) { SwDBData aTmp(pSh->GetDBData()); m_xDatabaseTLB->Select(aTmp.sDataSource, aTmp.sCommand, u""); @@ -197,15 +196,16 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* ) aData.sDataSource = m_xDatabaseTLB->GetDBName(sTableName, sColumnName, &bIsTable); aData.sCommand = sTableName; aData.nCommandType = bIsTable ? 0 : 1; - SwWrtShell *pSh = CheckAndGetWrtShell(); - assert(pSh); - SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager(); - if (pDbManager) - pDbManager->CommitLastRegistrations(); + if (SwWrtShell *pSh = CheckAndGetWrtShell()) + { + SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager(); + if (pDbManager) + pDbManager->CommitLastRegistrations(); - if (aData.sDataSource.isEmpty()) - aData = pSh->GetDBData(); + if (aData.sDataSource.isEmpty()) + aData = pSh->GetDBData(); + } if(!aData.sDataSource.isEmpty()) // without database no new field command { @@ -292,8 +292,6 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) if (nOld == GetTypeSel()) return; - SwWrtShell *pSh = CheckAndGetWrtShell(); - assert(pSh); bool bCond = false, bSetNo = false, bFormat = false, bDBFormat = false; const SwFieldTypesEnum nTypeId = static_cast<SwFieldTypesEnum>(m_xTypeLB->get_id(GetTypeSel()).toUInt32()); @@ -315,7 +313,8 @@ void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox) { if (auto *const pField = dynamic_cast<SwDBNameInfField*>(GetCurField())) { - aData = pField->GetDBData(pSh->GetDoc()); + if(SwWrtShell *pSh = CheckAndGetWrtShell()) + aData = pField->GetDBData(pSh->GetDoc()); } } m_xDatabaseTLB->Select(aData.sDataSource, aData.sCommand, sColumnName); diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index d4de4413fffb..e84dcda1e780 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -312,7 +312,7 @@ IMPL_LINK_NOARG(SwFieldFuncPage, TypeHdl, weld::TreeView&, void) m_xNameED->SetDropEnable(true); m_xValueFT->set_label(SwResId(STR_INSTEXT)); SwWrtShell* pSh = GetActiveWrtShell(); - if (!IsFieldEdit() && pSh ) + if (!IsFieldEdit() && pSh) m_xValueED->set_text(pSh->GetSelText()); bName = bValue = true; m_xNameED->set_accessible_name(m_xNameFT->get_label()); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index b7a30d589196..ea8e41414d4a 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -198,7 +198,6 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) SwWrtShell *pSh = GetWrtShell(); if (!pSh) pSh = ::GetActiveWrtShell(); - if (!pSh) return; @@ -490,8 +489,11 @@ void SwFieldRefPage::SubTypeHdl() void SwFieldRefPage::UpdateSubType(const OUString& filterString) { SwWrtShell *pSh = GetWrtShell(); - if(!pSh) + if (!pSh) pSh = ::GetActiveWrtShell(); + if (!pSh) + return; + SwGetRefField const*const pRefField(dynamic_cast<SwGetRefField*>(GetCurField())); const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32(); @@ -980,13 +982,12 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* ) SwGetRefField const*const pRefField(dynamic_cast<SwGetRefField*>(GetCurField())); - if (REFFLDFLAG & nTypeId) + SwWrtShell *pSh = GetWrtShell(); + if(!pSh) + pSh = ::GetActiveWrtShell(); + + if (pSh && REFFLDFLAG & nTypeId) { - SwWrtShell *pSh = GetWrtShell(); - if(!pSh) - { - pSh = ::GetActiveWrtShell(); - } if (nTypeId == REFFLDFLAG_BOOKMARK) // text marks! { aName = m_xNameED->get_text(); |