RESOLVED FIXED 76750
[windows] Convert usage of GetDC to HWndDC Part 2.
https://bugs.webkit.org/show_bug.cgi?id=76750
Summary [windows] Convert usage of GetDC to HWndDC Part 2.
David Levin
Reported 2012-01-20 16:10:39 PST
These usages are where I changed (usually buggy) functionality. Usually these were leaks. In one case, I reduced the lifetime of a dc because it allowed for simpler code (when using an RAII class like HWndDC). In another case, the code was using OwnPtr<HDC> when it should not have been so the HDC was getting deleted when it should have been released.
Attachments
Patch (10.13 KB, patch)
2012-01-20 16:16 PST, David Levin
aroben: review+
aroben: commit-queue-
David Levin
Comment 1 2012-01-20 16:16:54 PST
WebKit Review Bot
Comment 2 2012-01-20 16:19:10 PST
Attachment 123402 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebKit/win/WebNodeHighlight.cpp:138: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] Source/WebKit/win/FullscreenVideoController.cpp:489: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] Source/WebKit2/Shared/win/ShareableBitmapWin.cpp:46: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] Source/WebKit/chromium/ChangeLog:3: ChangeLog entry has no bug number [changelog/bugnumber] [5] Total errors found: 4 in 31 files If any of these errors are false positives, please file a bug against check-webkit-style.
David Levin
Comment 3 2012-01-20 16:29:51 PST
(In reply to comment #2) > Attachment 123402 [details] did not pass style-queue: > > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 > > Source/WebKit/win/WebNodeHighlight.cpp:138: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] > Source/WebKit/win/FullscreenVideoController.cpp:489: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] > Source/WebKit2/Shared/win/ShareableBitmapWin.cpp:46: Use OwnPtr<HDC> when calling CreateCompatibleDC to avoid potential memory leaks. [runtime/leaky_pattern] [5] > Source/WebKit/chromium/ChangeLog:3: ChangeLog entry has no bug number [changelog/bugnumber] [5] > Total errors found: 4 in 31 files > > > If any of these errors are false positives, please file a bug against check-webkit-style. Filed: https://bugs.webkit.org/show_bug.cgi?id=76752
Adam Roben (:aroben)
Comment 4 2012-01-23 08:30:30 PST
Comment on attachment 123402 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=123402&action=review > Source/WebKit/win/FullscreenVideoController.cpp:494 > - HDC windowDC = GetDC(m_hudWindow); > - HDC bitmapDC = CreateCompatibleDC(windowDC); > - ::ReleaseDC(m_hudWindow, windowDC); > - HGDIOBJ oldBitmap = SelectObject(bitmapDC, m_bitmap.get()); > + OwnPtr<HDC> bitmapDC = createCompatibleDCForWindow(m_hudWindow); I don't think the separate function is needed. You can just do: OwnPtr<HDC> bitmapDC = CreateCompatibleDC(HwndDC(m_hudWindow));
David Levin
Comment 5 2012-01-23 17:32:01 PST
Committed as http://trac.webkit.org/changeset/105667 (In reply to comment #4) > (From update of attachment 123402 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=123402&action=review > > + OwnPtr<HDC> bitmapDC = createCompatibleDCForWindow(m_hudWindow); > > I don't think the separate function is needed. You can just do: OwnPtr<HDC> bitmapDC = CreateCompatibleDC(HwndDC(m_hudWindow)); Done.
Note You need to log in before you can comment on or make changes to this bug.