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

Side by Side Diff: src/gpu/GrAutoLocaleSetter.h

Issue 1514083002: Fix intermittent GrAutoLocaleSetter crashes on Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrAutoLocaleSetter_DEFINED 8 #ifndef GrAutoLocaleSetter_DEFINED
9 #define GrAutoLocaleSetter_DEFINED 9 #define GrAutoLocaleSetter_DEFINED
10 10
11 #include "GrTypes.h" 11 #include "GrTypes.h"
12 12
13 #if defined(SK_BUILD_FOR_WIN)
14 #include "SkString.h"
15 #endif
16
13 #if !defined(SK_BUILD_FOR_ANDROID) 17 #if !defined(SK_BUILD_FOR_ANDROID)
14 #include <locale.h> 18 #include <locale.h>
15 #endif 19 #endif
16 20
17 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 21 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
18 #include <xlocale.h> 22 #include <xlocale.h>
19 #endif 23 #endif
20 24
21 /** 25 /**
22 * Helper class for ensuring that we don't use the wrong locale when building sh aders. Android 26 * Helper class for ensuring that we don't use the wrong locale when building sh aders. Android
(...skipping 12 matching lines...) Expand all
35 } else { 39 } else {
36 fOldLocale = static_cast<locale_t>(0); 40 fOldLocale = static_cast<locale_t>(0);
37 } 41 }
38 #else 42 #else
39 (void) name; // suppress unused param warning. 43 (void) name; // suppress unused param warning.
40 #endif 44 #endif
41 } 45 }
42 46
43 ~GrAutoLocaleSetter () { 47 ~GrAutoLocaleSetter () {
44 #if defined(SK_BUILD_FOR_WIN) 48 #if defined(SK_BUILD_FOR_WIN)
45 if (fOldLocale) { 49 if (!fOldLocale.isEmpty()) {
bsalomon 2015/12/10 15:12:23 IIUC empty string is valid. "If locale points to a
Kimmo Kinnunen 2015/12/11 07:50:17 Done.
46 setlocale(LC_ALL, fOldLocale); 50 setlocale(LC_ALL, fOldLocale.c_str());
47 } 51 }
48 _configthreadlocale(fOldPerThreadLocale); 52 _configthreadlocale(fOldPerThreadLocale);
49 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) 53 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__)
50 if (fLocale) { 54 if (fLocale) {
51 uselocale(fOldLocale); 55 uselocale(fOldLocale);
52 freelocale(fLocale); 56 freelocale(fLocale);
53 } 57 }
54 #endif 58 #endif
55 } 59 }
56 60
57 private: 61 private:
58 #if defined(SK_BUILD_FOR_WIN) 62 #if defined(SK_BUILD_FOR_WIN)
59 int fOldPerThreadLocale; 63 int fOldPerThreadLocale;
60 const char* fOldLocale; 64 SkString fOldLocale;
61 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) 65 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__)
62 locale_t fOldLocale; 66 locale_t fOldLocale;
63 locale_t fLocale; 67 locale_t fLocale;
64 #endif 68 #endif
65 }; 69 };
66 70
67 #endif 71 #endif
68 72
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698