summaryrefslogtreecommitdiff
path: root/basctl/source/basicide
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-02-07 20:37:37 +0000
committerCaolán McNamara <caolanm@redhat.com>2023-02-08 09:00:40 +0000
commite1e6ff49a244039bc2c2c09026ab9ca3ef96e859 (patch)
tree5c75547f143a2437bfe9b24994ac61f55e9c09ea /basctl/source/basicide
parentbad7bb439461ab0d50b44260c7274b05758d8e1f (diff)
tdf#153434 crash on "new" macro with no cursor
probably good in trunk since: commit 6e2bd11251afbe64f9889ede36b28b00f47aaff5 Date: Sun Aug 7 12:49:11 2022 +0100 tdf#150291 Revert "Fix crash when no valid EntryDescriptor found" but still visible in 7-4 Change-Id: I63898ed3e33f73f8a93528872449539c5df6574f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146645 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl/source/basicide')
-rw-r--r--basctl/source/basicide/macrodlg.cxx35
1 files changed, 28 insertions, 7 deletions
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index b1097b9ad8c8..e2511ee53b6b 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -295,7 +295,11 @@ void MacroChooser::DeleteMacro()
SbMethod* MacroChooser::CreateMacro()
{
SbMethod* pMethod = nullptr;
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return nullptr;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" );
@@ -474,8 +478,9 @@ IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void)
IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void)
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
- SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
+ SbModule* pModule = nullptr;
+ if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get()))
+ pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
m_xMacroBox->clear();
if (pModule)
{
@@ -614,7 +619,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -697,7 +706,11 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xAssignButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
@@ -724,14 +737,22 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xNewLibButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
createLibImpl(m_xDialog.get(), aDocument, nullptr, m_xBasicBox.get());
}
else if (&rButton == m_xNewModButton.get())
{
- m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ if (!m_xBasicBox->get_cursor(m_xBasicBoxIter.get()) && !m_xBasicBox->get_iter_first(*m_xBasicBoxIter))
+ {
+ SAL_WARN("basctl.basicide", "neither cursor set nor root entry to use as fallback");
+ return;
+ }
EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );