Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_x11.cc

Issue 1011173003: x11: Use gfx::XScopedPtr<> in more places. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_screen_x11.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index ed8a0f4844cd7f002c6d1c492eff05575ebedf81..fe5231964a92a366afed5e4b75b40c73cc678e68 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -259,8 +259,10 @@ DesktopScreenX11::DesktopScreenX11(
std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
std::vector<gfx::Display> displays;
- XRRScreenResources* resources =
- XRRGetScreenResourcesCurrent(xdisplay_, x_root_window_);
+ gfx::XScopedPtr<
+ XRRScreenResources,
+ gfx::XObjectDeleter<XRRScreenResources, void, XRRFreeScreenResources>>
+ resources(XRRGetScreenResourcesCurrent(xdisplay_, x_root_window_));
if (!resources) {
LOG(ERROR) << "XRandR returned no displays. Falling back to Root Window.";
return GetFallbackDisplayList();
@@ -278,19 +280,18 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
float device_scale_factor = 1.0f;
for (int i = 0; i < resources->noutput; ++i) {
RROutput output_id = resources->outputs[i];
- XRROutputInfo* output_info =
- XRRGetOutputInfo(xdisplay_, resources, output_id);
+ gfx::XScopedPtr<XRROutputInfo,
+ gfx::XObjectDeleter<XRROutputInfo, void, XRRFreeOutputInfo>>
+ output_info(XRRGetOutputInfo(xdisplay_, resources.get(), output_id));
bool is_connected = (output_info->connection == RR_Connected);
- if (!is_connected) {
- XRRFreeOutputInfo(output_info);
+ if (!is_connected)
continue;
- }
if (output_info->crtc) {
- XRRCrtcInfo *crtc = XRRGetCrtcInfo(xdisplay_,
- resources,
- output_info->crtc);
+ gfx::XScopedPtr<XRRCrtcInfo,
+ gfx::XObjectDeleter<XRRCrtcInfo, void, XRRFreeCrtcInfo>>
+ crtc(XRRGetCrtcInfo(xdisplay_, resources.get(), output_info->crtc));
int64 display_id = -1;
if (!ui::GetDisplayId(output_id, static_cast<uint8>(i), &display_id)) {
@@ -336,15 +337,9 @@ std::vector<gfx::Display> DesktopScreenX11::BuildDisplaysFromXRandRInfo() {
}
displays.push_back(display);
-
- XRRFreeCrtcInfo(crtc);
}
-
- XRRFreeOutputInfo(output_info);
}
- XRRFreeScreenResources(resources);
-
if (displays.empty())
return GetFallbackDisplayList();
« no previous file with comments | « ui/display/chromeos/x11/native_display_delegate_x11.cc ('k') | ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698