Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


On 04/12/2015 08:50 AM, julien2412 wrote:
I read about tdf#90566, Theme::disposing(void) memory leak:
maChangeListeners is not properly disposed and wondered why we couldn't just
remove the 2 first lines of the disposing function (see
http://opengrok.libreoffice.org/xref/core/sfx2/source/sidebar/Theme.cxx#390)
+ replace "aListeners" by "maChangeListeners"?
I mean why adding an intermediate variable instead of just using the initial
variable?

The general reason for this construct is multi-threading: Access to the maChangeListeners member typically needs to be guarded by some mutex (typically a member of the same class instance as maChangeListeners), and the calls "out of that instance" to the

  (*iListener)->disposing(aEvent);

must be done with that mutex not locked (to avoid deadlock). That is why the generic skeleton is

  Listeners copy;
  {
    Guard g(mMutex);
    copy = mListeners;
  }
  for (i: copy) i->...

However, in this particular case, the access to maChangeListeners is not guarded, but likely out of ignorance of the original author.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.