Bug 155720 - unsafe static map "bSkippedFirstInit"
Summary: unsafe static map "bSkippedFirstInit"
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
Whiteboard: target:24.2.0
Depends on:
Reported: 2023-06-07 16:29 UTC by Caolán McNamara
Modified: 2023-09-12 07:17 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Caolán McNamara 2023-06-07 16:29:58 UTC
we have a:
static std::map<const void*, bool> bSkippedFirstInit

const SfxViewShell* pViewShell = SfxViewShell::Current();
if (bSkippedFirstInit.find(pViewShell) == bSkippedFirstInit.end())
    bSkippedFirstInit[pViewShell] = true;
... other stuff...


commit adb901ca11afa5a153ecd433375b9ab1dfc2fd03
Date:   Mon Aug 3 09:40:31 2020 +0200

    notebookbar: control early init per view

but the map is never cleared and it is surely possible that a SfxViewShell* is put into the map, then that SfxViewShell deleted and a new one created with the same address and the logic then doesn't make sense

Steps to Reproduce:
1. breakpoint in SfxNotebookBar::StateMethod

Actual Results:
ResetActiveToolbarModeToDefault is called

Expected Results:
not where

Reproducible: Always

User Profile Reset: Yes

Additional Info:
other commits around here are:

commit 42cc32c95db2484961a65c906af1a899c1a6aa2b
Date:   Fri Jul 31 11:30:21 2020 +0200

    Notebookbar: skip early init
    This will prevent us from hanging in the start
    center during notebookbar initialization.
    Also prevents from bugs due to uno state querying
    too early: eg. Paste Special was not working in LOK.
Comment 1 Caolán McNamara 2023-06-07 16:32:57 UTC
I wonder if we still need this workaround, or at least if we know how to reproduce the original problem that needed it?

I think that because of this we occasionally tear down our notebookbar and recreate it, and I can see that happen as part of https://github.com/CollaboraOnline/online/issues/6511 and our cache clean up in

commit d8b834a750a284ecd04cac1f4de4cb9cbf05c42c
Date:   Fri Jun 2 18:31:55 2023 +0200

    Styles preview cache cleanup on exit

can fire when the notebookbar is destroyed, only to need it again a small time period later when it is recreated
Comment 2 Szymon Kłos 2023-06-16 06:41:24 UTC
Original bug description (bug in Collabora Online):

"Apparently this bug only occurs with notebookbar enabled. It's fine with classic toolbar.

Open a document, copy a piece of text via Ctrl-C, and press Ctrl-Shift-V to open the Paste Special dialog.

-> Nothing happens."

It was bisected to: https://cgit.freedesktop.org/libreoffice/core/commit/?id=a09b5f46c4b577668e2f5b4450dab3e4eb7e6066

Note: I think paste special dialog appears on Ctrl+Shift+Alt+V  then Ctrl+V to confirm

It seems dialog appears even without that workaround so probalby is no longer needed.
Comment 3 Caolán McNamara 2023-06-16 07:55:00 UTC
very nice if we don't need it anymore
Comment 4 Commit Notification 2023-06-16 18:20:18 UTC
Szymon Kłos committed a patch related to this issue.
It has been pushed to "master":


tdf#155720 remove old skip notebookbar init workaround

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:

Affected users are encouraged to test the fix and report feedback.