Kaydet (Commit) ed7ad72a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Make ToolBox::SetItemBits work for disposed instances

I happened to come across a SEGV caused by a null ToolBox::mpData once, as
below.  Interestingly, some ToolBox member functions like GetItemPos and
GetItemCount do take a potential null mpData (after a call to dispose) into
account.

> #0  0x00007fffebc1b93c in std::__cxx1998::vector<ImplToolItem, std::allocator<ImplToolItem> >::size() const (this=0x20) at /usr/include/c++/7/bits/stl_vector.h:671
> #1  0x00007fffebc172ce in ToolBox::SetItemBits(unsigned short, ToolBoxItemBits) (this=0x7ffec6449230, nItemId=16, nBits=ToolBoxItemBits::DROPDOWN) at /data/sbergman/lo-ro/source/vcl/source/window/toolbox2.cxx:889
> #2  0x00007ffff07ccc42 in SvxClipBoardControl::StateChanged(unsigned short, SfxItemState, SfxPoolItem const*) (this=0x7ffec6420390, nSID=5312, eState=SfxItemState::DEFAULT, pState=0xad4cf60) at /data/sbergman/lo-ro/source/svx/source/mnuctrls/clipboardctl.cxx:116
> #3  0x00007ffff1d69c4f in SfxToolBoxControl::statusChanged(com::sun::star::frame::FeatureStateEvent const&) (this=0x7ffec6420390, rEvent=...) at /data/sbergman/lo-ro/source/sfx2/source/toolbox/tbxitem.cxx:521
> #4  0x00007ffff193e163 in SfxDispatchController_Impl::addStatusListener(com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> const&, com::sun::star::util::URL const&) (this=0xaa3da80, aListener=uno::Reference to (SvxClipBoardControl *) 0x7ffec64203b8, aURL=...) at /data/sbergman/lo-ro/source/sfx2/source/control/unoctitm.cxx:865
> #5  0x00007ffff193ddfc in SfxOfficeDispatch::addStatusListener(com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> const&, com::sun::star::util::URL const&) (this=0xaffa990, aListener=uno::Reference to (SvxClipBoardControl *) 0x7ffec64203b8, aURL=...) at /data/sbergman/lo-ro/source/sfx2/source/control/unoctitm.cxx:250
> #6  0x00007fffee75c7e4 in svt::ToolboxController::bindListener() (this=0x7ffec6420390) at /data/sbergman/lo-ro/source/svtools/source/uno/toolboxcontroller.cxx:529
> #7  0x00007fffee75c056 in svt::ToolboxController::update() (this=0x7ffec6420390) at /data/sbergman/lo-ro/source/svtools/source/uno/toolboxcontroller.cxx:227
> #8  0x00007fffc11ddef6 in framework::ToolBarManager::UpdateControllers() (this=0x7ffec6142930) at /data/sbergman/lo-ro/source/framework/source/uielement/toolbarmanager.cxx:364
> #9  0x00007fffc11e995e in framework::ToolBarManager::AsyncUpdateControllersHdl(Timer*) (this=0x7ffec6142930) at /data/sbergman/lo-ro/source/framework/source/uielement/toolbarmanager.cxx:1852
> #10 0x00007fffc11dc748 in framework::ToolBarManager::LinkStubAsyncUpdateControllersHdl(void*, Timer*) (instance=0x7ffec6142930, data=0x7ffec6142b00) at /data/sbergman/lo-ro/source/framework/source/uielement/toolbarmanager.cxx:1839
> #11 0x00007fffec264928 in Link<Timer*, void>::Call(Timer*) const (this=0x7ffec6142b20, data=0x7ffec6142b00) at /data/sbergman/lo-ro/source/include/tools/link.hxx:84
> #12 0x00007fffec264787 in Timer::Invoke() (this=0x7ffec6142b00) at /data/sbergman/lo-ro/source/vcl/source/app/timer.cxx:76
> #13 0x00007fffec21cdd2 in Scheduler::ProcessTaskScheduling() () at /data/sbergman/lo-ro/source/vcl/source/app/scheduler.cxx:448
> #14 0x00007fffec21bfed in Scheduler::CallbackTaskScheduling() () at /data/sbergman/lo-ro/source/vcl/source/app/scheduler.cxx:270
> #15 0x00007fffcdfaa036 in SalTimer::CallCallback() (this=0x199ae40) at /data/sbergman/lo-ro/source/vcl/inc/saltimer.hxx:55
> #16 0x00007fffcdfa920d in sal_gtk_timeout_dispatch(_GSource*, int (*)(void*), void*) (pSource=0x7e1abe0) at /data/sbergman/lo-ro/source/vcl/unx/gtk3/gtk3gtkdata.cxx:692
> #17 0x00007ffff5aa7b77 in g_main_dispatch (context=0x63d8d0) at /usr/src/debug/glib2-2.54.3-2.fc27.x86_64/glib/gmain.c:3142
> #18 0x00007ffff5aa7b77 in g_main_context_dispatch (context=context@entry=0x63d8d0) at /usr/src/debug/glib2-2.54.3-2.fc27.x86_64/glib/gmain.c:3795
> #19 0x00007ffff5aa7f20 in g_main_context_iterate (context=context@entry=0x63d8d0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at /usr/src/debug/glib2-2.54.3-2.fc27.x86_64/glib/gmain.c:3868
> #20 0x00007ffff5aa7fac in g_main_context_iteration (context=0x63d8d0, may_block=1) at /usr/src/debug/glib2-2.54.3-2.fc27.x86_64/glib/gmain.c:3929
> #21 0x00007fffcdfa78f4 in GtkSalData::Yield(bool, bool) (this=0x63ae70, bWait=true, bHandleAllCurrentEvents=false) at /data/sbergman/lo-ro/source/vcl/unx/gtk3/gtk3gtkdata.cxx:459
> #22 0x00007fffcdfabf07 in GtkInstance::DoYield(bool, bool) (this=0x6e6a90, bWait=true, bHandleAllCurrentEvents=false) at /data/sbergman/lo-ro/source/vcl/unx/gtk/gtkinst.cxx:412
> #23 0x00007fffec2515ca in ImplYield(bool, bool) (i_bWait=true, i_bAllEvents=false) at /data/sbergman/lo-ro/source/vcl/source/app/svapp.cxx:472
> #24 0x00007fffec24c2c4 in Application::Yield() () at /data/sbergman/lo-ro/source/vcl/source/app/svapp.cxx:537
> #25 0x00007fffec24c24e in Application::Execute() () at /data/sbergman/lo-ro/source/vcl/source/app/svapp.cxx:452
> #26 0x00007ffff774d617 in desktop::Desktop::Main() (this=0x7fffffff2950) at /data/sbergman/lo-ro/source/desktop/source/app/app.cxx:1623
> #27 0x00007fffec260825 in ImplSVMain() () at /data/sbergman/lo-ro/source/vcl/source/app/svmain.cxx:198
> #28 0x00007fffec262498 in SVMain() () at /data/sbergman/lo-ro/source/vcl/source/app/svmain.cxx:236
> #29 0x00007ffff77bba98 in soffice_main() () at /data/sbergman/lo-ro/source/desktop/source/app/sofficemain.cxx:166
> #30 0x000000000040086d in sal_main () at /data/sbergman/lo-ro/source/desktop/source/app/main.c:48
> #31 0x0000000000400847 in main (argc=4, argv=0x7fffffff2c98) at /data/sbergman/lo-ro/source/desktop/source/app/main.c:47

Change-Id: I622b4128de0a6be294b59caf2bb2d6f7b529c349
Reviewed-on: https://gerrit.libreoffice.org/52086Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 29d4ecf3
...@@ -886,7 +886,7 @@ void ToolBox::SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ) ...@@ -886,7 +886,7 @@ void ToolBox::SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits )
{ {
ImplToolItems::size_type nPos = GetItemPos( nItemId ); ImplToolItems::size_type nPos = GetItemPos( nItemId );
if ( nPos < mpData->m_aItems.size() ) if ( nPos < GetItemCount() )
{ {
ToolBoxItemBits nOldBits = mpData->m_aItems[nPos].mnBits; ToolBoxItemBits nOldBits = mpData->m_aItems[nPos].mnBits;
mpData->m_aItems[nPos].mnBits = nBits; mpData->m_aItems[nPos].mnBits = nBits;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment