Bug 122688 - Introduce reference counting for HDC
Summary: Introduce reference counting for HDC
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All Windows (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-13 11:24 UTC by Dmitriy Shilin
Modified: 2019-07-08 15:57 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitriy Shilin 2019-01-13 11:24:16 UTC
ScopedSelectedHPEN was introduced during the implementation of smart pointers
for various GDI objects [1], [2]. It uses the device context object, HDC, [3]
internally with an assumption that the HDC object will be valid during the
ScopedSelectedHPEN life time. This assumption was made because the entire
codebase is relied on this fact.

As discussed in [2] (refer to the Mike Kaganski's comments) it is better to
introduce some kind of SharedHDC based on std::shared_ptr and make
ScopedSelectedHPEN to use the SharedHDC instead of a raw pointer.

As a result the ScopedSelectedHPEN wouldn't require to know anything about the
lifetime of the device context.

1. https://bugs.documentfoundation.org/show_bug.cgi?id=107792
2. https://gerrit.libreoffice.org/#/c/65963/
3. https://docs.microsoft.com/en-us/windows/desktop/gdi/device-contexts
Comment 1 Mike Kaganski 2019-01-21 12:19:29 UTC
This should stay unconfirmed for now, until we find a place where this would be necessary/helpful. My comment was based on poor overall knowledge of the current status of GDI code in LO. If it's actually (yet) relies on HDC being valid during the lifetime of dependent objects, then no need to implement some functionality "just in case" for a future use. Only do when the assumption is proven wrong, or is difficult to keep.
Comment 2 Xisco Faulí 2019-03-21 12:49:38 UTC
ok, let's keep it unconfirmed for the time being.
I close this issue as RESOLVED WONTFIX after 6 month if it's still unconfirmed...
Comment 3 Xisco Faulí 2019-07-08 15:57:51 UTC
(In reply to Mike Kaganski from comment #1)
> This should stay unconfirmed for now, until we find a place where this would
> be necessary/helpful. My comment was based on poor overall knowledge of the
> current status of GDI code in LO. If it's actually (yet) relies on HDC being
> valid during the lifetime of dependent objects, then no need to implement
> some functionality "just in case" for a future use. Only do when the
> assumption is proven wrong, or is difficult to keep.

Closing as RESOLVED WONTFIX after 6 months...
@Dmitriy, note this issue can be moved back to UNCONFIRMED and re-evaluated at any time...