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

Side by Side Diff: chrome/browser/chromeos/input_method/xkeyboard.cc

Issue 9333005: Fix some memory leaks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 5 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <cstring> 8 #include <cstring>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 XkbDescPtr xkb_desc = 257 XkbDescPtr xkb_desc =
258 XkbGetKeyboard(ui::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); 258 XkbGetKeyboard(ui::GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd);
259 if (!xkb_desc) { 259 if (!xkb_desc) {
260 return kBadMask; 260 return kBadMask;
261 } 261 }
262 262
263 if (xkb_desc->dpy && xkb_desc->names && xkb_desc->names->vmods) { 263 if (xkb_desc->dpy && xkb_desc->names && xkb_desc->names->vmods) {
264 const std::string string_to_find(kNumLockVirtualModifierString); 264 const std::string string_to_find(kNumLockVirtualModifierString);
265 for (size_t i = 0; i < XkbNumVirtualMods; ++i) { 265 for (size_t i = 0; i < XkbNumVirtualMods; ++i) {
266 const unsigned int virtual_mod_mask = 1U << i; 266 const unsigned int virtual_mod_mask = 1U << i;
267 char* virtual_mod_str = 267 ui::XScopedString virtual_mod_str(
268 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i]); 268 XGetAtomName(xkb_desc->dpy, xkb_desc->names->vmods[i]));
269 if (!virtual_mod_str) { 269 if (!virtual_mod_str.string())
270 continue; 270 continue;
271 } 271 if (string_to_find == virtual_mod_str.string()) {
272 if (string_to_find == virtual_mod_str) {
273 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) { 272 if (!XkbVirtualModsToReal(xkb_desc, virtual_mod_mask, &real_mask)) {
274 LOG(ERROR) << "XkbVirtualModsToReal failed"; 273 LOG(ERROR) << "XkbVirtualModsToReal failed";
275 real_mask = kBadMask; // reset the return value, just in case. 274 real_mask = kBadMask; // reset the return value, just in case.
276 } 275 }
277 XFree(virtual_mod_str);
278 break; 276 break;
279 } 277 }
280 XFree(virtual_mod_str);
281 } 278 }
282 } 279 }
283 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */); 280 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */);
284 return real_mask; 281 return real_mask;
285 } 282 }
286 283
287 void XKeyboardImpl::GetLockedModifiers(bool* out_caps_lock_enabled, 284 void XKeyboardImpl::GetLockedModifiers(bool* out_caps_lock_enabled,
288 bool* out_num_lock_enabled) { 285 bool* out_num_lock_enabled) {
289 // For now, don't call CHECK() here to make 286 // For now, don't call CHECK() here to make
290 // TabRestoreServiceTest.DontRestorePrintPreviewTab test happy. 287 // TabRestoreServiceTest.DontRestorePrintPreviewTab test happy.
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return false; 553 return false;
557 } 554 }
558 555
559 // static 556 // static
560 XKeyboard* XKeyboard::Create(const InputMethodUtil& util) { 557 XKeyboard* XKeyboard::Create(const InputMethodUtil& util) {
561 return new XKeyboardImpl(util); 558 return new XKeyboardImpl(util);
562 } 559 }
563 560
564 } // namespace input_method 561 } // namespace input_method
565 } // namespace chromeos 562 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698