OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 assert(g_xserver_error_trap_enabled); | 30 assert(g_xserver_error_trap_enabled); |
31 g_last_xserver_error_code = error_event->error_code; | 31 g_last_xserver_error_code = error_event->error_code; |
32 return 0; | 32 return 0; |
33 } | 33 } |
34 | 34 |
35 #endif // !defined(TOOLKIT_GTK) | 35 #endif // !defined(TOOLKIT_GTK) |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 XErrorTrap::XErrorTrap(Display* display) | 39 XErrorTrap::XErrorTrap(Display* display) |
40 : original_error_handler_(NULL), | 40 : original_error_handler_(nullptr), enabled_(true) { |
41 enabled_(true) { | |
42 #if defined(TOOLKIT_GTK) | 41 #if defined(TOOLKIT_GTK) |
43 gdk_error_trap_push(); | 42 gdk_error_trap_push(); |
44 #else // !defined(TOOLKIT_GTK) | 43 #else // !defined(TOOLKIT_GTK) |
45 assert(!g_xserver_error_trap_enabled); | 44 assert(!g_xserver_error_trap_enabled); |
46 original_error_handler_ = XSetErrorHandler(&XServerErrorHandler); | 45 original_error_handler_ = XSetErrorHandler(&XServerErrorHandler); |
47 g_xserver_error_trap_enabled = true; | 46 g_xserver_error_trap_enabled = true; |
48 g_last_xserver_error_code = 0; | 47 g_last_xserver_error_code = 0; |
49 #endif // !defined(TOOLKIT_GTK) | 48 #endif // !defined(TOOLKIT_GTK) |
50 } | 49 } |
51 | 50 |
52 int XErrorTrap::GetLastErrorAndDisable() { | 51 int XErrorTrap::GetLastErrorAndDisable() { |
53 enabled_ = false; | 52 enabled_ = false; |
54 #if defined(TOOLKIT_GTK) | 53 #if defined(TOOLKIT_GTK) |
55 return gdk_error_trap_push(); | 54 return gdk_error_trap_push(); |
56 #else // !defined(TOOLKIT_GTK) | 55 #else // !defined(TOOLKIT_GTK) |
57 assert(g_xserver_error_trap_enabled); | 56 assert(g_xserver_error_trap_enabled); |
58 XSetErrorHandler(original_error_handler_); | 57 XSetErrorHandler(original_error_handler_); |
59 g_xserver_error_trap_enabled = false; | 58 g_xserver_error_trap_enabled = false; |
60 return g_last_xserver_error_code; | 59 return g_last_xserver_error_code; |
61 #endif // !defined(TOOLKIT_GTK) | 60 #endif // !defined(TOOLKIT_GTK) |
62 } | 61 } |
63 | 62 |
64 XErrorTrap::~XErrorTrap() { | 63 XErrorTrap::~XErrorTrap() { |
65 if (enabled_) | 64 if (enabled_) |
66 GetLastErrorAndDisable(); | 65 GetLastErrorAndDisable(); |
67 } | 66 } |
68 | 67 |
69 } // namespace webrtc | 68 } // namespace webrtc |
OLD | NEW |