<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - With Screen Reader NVDA LibreOffice Crashes if a Word Count is Performed"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=135330#c8">Comment # 8</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - With Screen Reader NVDA LibreOffice Crashes if a Word Count is Performed"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=135330">bug 135330</a>
              from <span class="vcard"><a class="email" href="mailto:mikekaganski@hotmail.com" title="Mike Kaganski <mikekaganski@hotmail.com>"> <span class="fn">Mike Kaganski</span></a>
</span></b>
        <pre><span class="quote">> static bool
> ImplHandleGetObject(HWND hWnd, LPARAM lParam, WPARAM wParam, LRESULT & nRet)
> {
>     // IA2 should be enabled automatically
>     AllSettings aSettings = Application::GetSettings();
>     MiscSettings aMisc = aSettings.GetMiscSettings();
>     aMisc.SetEnableATToolSupport( true );
>     aSettings.SetMiscSettings( aMisc );
>     Application::SetSettings( aSettings );
>     ...</span >

So I see a bunch of problems here. Some background:

AllSettings has a shared pointer to ImplAllSettingsData.
ImplAllSettingsData includes a MiscSettings, which has a shared pointer to
ImplMiscData.

So in the end, aMisc has a shared pointer to the same ImplMiscData as used in
Application::GetSettings. So aMisc.SetEnableATToolSupport, although looks like
operating on a "copy" of a const reference returned by those const member
functions Application::GetSettings and AllSettings::GetMiscSettings, in fact
changes the shared state. Is this intentional? Not here, but elsewhere, where a
similar thing might happen?

Then AllSettings::SetMiscSettings calls CopyData, which checks use count, which
is naturally >1 (we have the local object in addition to the global one, both
referencing same data), and duplicates everything. Then in
Application::SetSettings, the copy will get , and original will be destroyed
... just because we changed true to true.

Because we do that unconditionally - even if
Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() is
already true. Why?

So one sure thing is to add a check before this; but how to proceed further?
should I keep this expensive replacement of all settings, or should I make use
of this implementation detail that aMisc.SetEnableATToolSupport already did all
I needed?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>