Files
odfstudio/basctl/source
Michael Weghorn 371bfd404f tdf#173273 basctl: Pass parent iter again in SbTreeListBox::ImpFindEntry
Before

    commit 4887919802
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Thu Jan 1 13:02:42 2026 +0100

        basctl: Return std::unique_ptr in SbTreeListBox::ImpFindEntry

, SbTreeListBox::ImpFindEntry was using an in/out weld::TreeIter&
param that passed the parent.

The above commit changed the method to return the
result instead of using the out param, but missed that
the param was also used as an input parameter.

Restore the input parameter, but keep returning the
result.

The above commit also caused weld::TreeView::iter_children
to be caused with an invalid iter, which in combination with

    commit 9d055f5261
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sat Jan 10 21:46:57 2026 +0100

        tdf#130857 weld: Filter dummy entries in base weld::TreeView::iter_children

would trigger a nullptr dereference for the vcl (SalInstanceTreeView)
implementation.

Making sure to pass a valid iter fixes that.

Also add an assert in SalInstanceTreeView::get_children_on_demand
to check that the iter that gets passed is actually valid which
would have triggered.

Backtrace of the crash seen for the tdf#173273 scenario
without this commit in place:

    1 __gnu_cxx::__normal_iterator<std::unique_ptr<SvTreeListEntry, std::default_delete<SvTreeListEntry>>const *, std::__cxx1998::vector<std::unique_ptr<SvTreeListEntry, std::default_delete<SvTreeListEntry>>>>::__normal_iterator stl_iterator.h 1059 0x7fb3db75e001
    2 std::__cxx1998::vector<std::unique_ptr<SvTreeListEntry, std::default_delete<SvTreeListEntry>>>::begin stl_vector.h 999 0x7fb3db75e001
    3 std::__cxx1998::vector<std::unique_ptr<SvTreeListEntry, std::default_delete<SvTreeListEntry>>>::empty stl_vector.h 1214 0x7fb3db75cd76
    4 SvTreeListEntry::HasChildren treelistentry.cxx 72 0x7fb3db7879ad
    5 SalInstanceTreeView::GetPlaceHolderChild salvtables.cxx 3550 0x7fb3dba702d1
    6 SalInstanceTreeView::get_children_on_demand salvtables.cxx 4436 0x7fb3dba76ec1
    7 weld::TreeView::iter_children TreeView.cxx 165 0x7fb3dbed1735
    8 basctl::SbTreeListBox::ImpFindEntry bastype2.cxx 551 0x7fb38b4c0fe2
    9 basctl::SbTreeListBox::SetCurrentEntry bastype2.cxx 830 0x7fb38b4c009a
    10 basctl::SbTreeListBox::UpdateEntries bastype2.cxx 638 0x7fb38b4c0eba
    11 basctl::SbTreeListBox::onDocumentCreated bastype2.cxx 563 0x7fb38b4c11e9
    12 basctl::DocumentEventNotifier::Impl::documentEventOccured doceventnotifier.cxx 164 0x7fb38b4f0a39
    13 comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent>::operator() interfacecontainer4.hxx 322 0x7fb3e1ef39d7
    14 comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::forEach<comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent>, (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1>(std::unique_lock<std::mutex>&, comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent>const&, (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1 const&) const interfacecontainer4.hxx 387 0x7fb3e1eefdd2
    15 comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::notifyEach<com::sun::star::document::DocumentEvent, (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1>(std::unique_lock<std::mutex>&, void (com::sun::star::document::XDocumentEventListener:: *)(com::sun::star::document::DocumentEvent const&), com::sun::star::document::DocumentEvent const&, (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1 const&) const interfacecontainer4.hxx 423 0x7fb3e1eef6e4
    16 (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener globalevents.cxx 487 0x7fb3e1eef505
    17 (anonymous namespace)::SfxGlobalEvents_Impl::documentEventOccured globalevents.cxx 226 0x7fb3e1eece4f
    18 (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>::operator() sfxbasemodel.cxx 3338 0x7fb3e1e79127
    19 comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::forEach<(anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>> interfacecontainer3.hxx 278 0x7fb3e1e6ab15
    20 SfxBaseModel::postEvent_Impl sfxbasemodel.cxx 3372 0x7fb3e1e6a263
    21 SfxBaseModel::Notify sfxbasemodel.cxx 3005 0x7fb3e1e6976c
    22 SfxBroadcaster::Broadcast SfxBroadcaster.cxx 43 0x7fb3e0f3d0bc
    23 (anonymous namespace)::SfxEventAsyncer_Impl::IdleHdl appcfg.cxx 109 0x7fb3e1848ce9
    24 (anonymous namespace)::SfxEventAsyncer_Impl::LinkStubIdleHdl appcfg.cxx 102 0x7fb3e184885d
    25 Link<Timer *, void>::Call link.hxx 105 0x7fb3dbb3bda1
    26 Timer::Invoke timer.cxx 75 0x7fb3dbb3bc0c
    27 Scheduler::CallbackTaskScheduling scheduler.cxx 615 0x7fb3dbae368d
    28 SalTimer::CallCallback saltimer.hxx 53 0x7fb3d2709822
    29 X11SalData::Timeout saldata.cxx 532 0x7fb3d270801f
    30 SalXLib::CheckTimeout saldata.cxx 616 0x7fb3d270853e
    31 SalXLib::Yield saldata.cxx 697 0x7fb3d2708c1e
    32 X11SalInstance::DoYield salinst.cxx 173 0x7fb3d27259cd
    33 InnerYield svapp.cxx 388 0x7fb3dbb0e996
    34 Application::Yield svapp.cxx 501 0x7fb3dbb0e21f
    35 Application::Execute svapp.cxx 363 0x7fb3dbb0e005
    36 desktop::Desktop::Main app.cxx 1679 0x7fb3e5b1de65
    37 ImplSVMainRun svmain.cxx 234 0x7fb3dbb38bfc
    38 SalInstance::SVMainRun salinst.hxx 108 0x7fb3d2726761
    39 ImplSVMain svmain.cxx 221 0x7fb3dbb38122
    40 SVMain svmain.cxx 252 0x7fb3dbb39cb9
    41 soffice_main sofficemain.cxx 122 0x7fb3e5b979aa
    42 sal_main main.c 51 0x55fc90ad69fd
    43 main main.c 49 0x55fc90ad69d7

Change-Id: I3b282533ec43fdd37bfdf8739ff51d25197bf8be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211603
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-09-30 13:45:05 +02:00
..