<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Introduce reference counting for GDI handles"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=107792#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Introduce reference counting for GDI handles"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=107792">bug 107792</a>
from <span class="vcard"><a class="email" href="mailto:kowtherh@gmail.com" title="Kowther Hassan <kowtherh@gmail.com>"> <span class="fn">Kowther Hassan</span></a>
</span></b>
<pre>(In reply to Markus Mohrhard from <a href="show_bug.cgi?id=107792#c0">comment #0</a>)
<span class="quote">> Currently we manually keep track of the lifecycle of GDI resources and
> delete them manually. Instead we should use a reference counted object that
> releases the handle as soon as we don't need it any more.
>
> Tomasz already introduced such a concept to fix one of our GDI handle leaks
> with
> <a href="https://cgit.freedesktop.org/libreoffice/core/commit/">https://cgit.freedesktop.org/libreoffice/core/commit/</a>
> ?id=dae61482df7ae540a1fb8feefbb92b5e7238444d
> That commit introduces a scoped version and we need additionally a reference
> counted version. These correspond to scoped_ptr and shared_ptr in C++.</span >
Hi I am an undergraduate student new to open source development and Libre
Office and an intermediate knowledge of C++ (I applied for GSoC). I want to
tackle this bug but have a few questions. I have not used shared_ptr,
scoped_ptr or anything to do with reference counting before.
- The example mentioned introduced the class ScopedHDC that deletes the object
for you.Is this fix just for HDC objects? Or are there other gdi objects? I am
not familiar with gdi. I see other objects such as HBITMAP, HBRUSH, HFONT that
are all manually destroyed using DeleteObject().
- Is this fix asking for an alternative to ScopedHDC class using shared
pointers or scoped pointers?
- For shared_ptr, my understanding is that you could create a shared_ptr object
using:
std::shared_ptr<HDC> hNewDC = std::make_shared<HDC>( CreateCompatibleDC(hDC) );
then use it as you would a regular pointer without having to call
DeleteDC(hNewDC) once your done. Is my understanding correct?</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>