summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-06-20 10:27:26 +0200
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-06-21 23:32:20 +0200
commitf894fa135bea1b33c51fd94e2138a7c9b16b2776 (patch)
treee4a6fe66e5736f53482c18b52822e738abb9cba5
parent3e24263d6174cd1e33c4216acbd0130b4ffa2dce (diff)
Fix crash when no valid EntryDescriptor found
When opening macro run dlg, the last selected entry is displayed again. When no entry was found, a crash occured in some situations (GetLastEntryDescriptor() returned garbage). Initialize m_aLastEntryDesc properly, and make sure the method returns when no last selected macro was found. Also fix some nullptr crashes which occurred during UITests Change-Id: I7bd1a0b8824725f9935876ae26d8222410a3bc25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136140 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> (cherry picked from commit 499ecbf3a36990c29dc7e1fb9b0ecb1d297c2848) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136170 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 2545a7700f8a4872fd18cb8b1fffeaa4599136d9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136236 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--basctl/source/basicide/iderdll.cxx1
-rw-r--r--basctl/source/basicide/macrodlg.cxx7
-rw-r--r--vcl/source/app/salvtables.cxx2
-rw-r--r--vcl/source/treelist/treelist.cxx6
4 files changed, 16 insertions, 0 deletions
diff --git a/basctl/source/basicide/iderdll.cxx b/basctl/source/basicide/iderdll.cxx
index 022045050e9a..8e8a3dc3e114 100644
--- a/basctl/source/basicide/iderdll.cxx
+++ b/basctl/source/basicide/iderdll.cxx
@@ -145,6 +145,7 @@ ExtraData* Dll::GetExtraData ()
ExtraData::ExtraData () :
+ m_aLastEntryDesc(EntryDescriptor()),
bChoosingMacro(false),
bShellInCriticalSection(false)
{
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 511abf83591e..b0abae8998c0 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -153,6 +153,13 @@ void MacroChooser::RestoreMacroDescription()
aDesc = pData->GetLastEntryDescriptor();
}
+ // No valid EntryDescriptor found
+ if (aDesc.GetMethodName().isEmpty())
+ {
+ m_xMacroNameEdit->select_region(0, 0);
+ return;
+ }
+
m_xBasicBox->SetCurrentEntry(aDesc);
BasicSelectHdl(m_xBasicBox->get_widget());
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 20e8db2e7726..6875b9fb9b45 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4638,6 +4638,8 @@ void SalInstanceTreeView::set_text(const weld::TreeIter& rIter, const OUString&
OUString SalInstanceTreeView::get_id(const weld::TreeIter& rIter) const
{
const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
+ if (!rVclIter.iter)
+ return OUString();
const OUString* pStr = static_cast<const OUString*>(rVclIter.iter->GetUserData());
if (pStr)
return *pStr;
diff --git a/vcl/source/treelist/treelist.cxx b/vcl/source/treelist/treelist.cxx
index 54ebcb075e92..a876b0675980 100644
--- a/vcl/source/treelist/treelist.cxx
+++ b/vcl/source/treelist/treelist.cxx
@@ -101,6 +101,8 @@ bool SvTreeList::IsEntryVisible( const SvListView* pView, SvTreeListEntry* pEntr
sal_uInt16 SvTreeList::GetDepth( const SvTreeListEntry* pEntry ) const
{
+ if (!pEntry)
+ return 0;
DBG_ASSERT(pEntry && pEntry!=pRootItem.get(),"GetDepth:Bad Entry");
sal_uInt16 nDepth = 0;
while( pEntry && pEntry->pParent != pRootItem.get() )
@@ -1505,6 +1507,8 @@ SvTreeListEntries& SvTreeList::GetChildList( SvTreeListEntry* pParent )
const SvTreeListEntry* SvTreeList::GetParent( const SvTreeListEntry* pEntry ) const
{
+ if (!pEntry)
+ return nullptr;
const SvTreeListEntry* pParent = pEntry->pParent;
if (pParent == pRootItem.get())
pParent = nullptr;
@@ -1513,6 +1517,8 @@ const SvTreeListEntry* SvTreeList::GetParent( const SvTreeListEntry* pEntry ) co
SvTreeListEntry* SvTreeList::GetParent( SvTreeListEntry* pEntry )
{
+ if (!pEntry)
+ return nullptr;
SvTreeListEntry* pParent = pEntry->pParent;
if (pParent == pRootItem.get())
pParent = nullptr;