summaryrefslogtreecommitdiffstats
path: root/ui/base/win
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-14 21:10:54 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-14 21:10:54 +0000
commit27f5d779cac0af5721fc4d9b50f06ab43746c197 (patch)
tree075df7c4df7462dcfcf84ed74f4b8bb48f74d4e3 /ui/base/win
parent7afe8b11627acec16f7db7096c1e18d9ca248e7c (diff)
downloadchromium_src-27f5d779cac0af5721fc4d9b50f06ab43746c197.zip
chromium_src-27f5d779cac0af5721fc4d9b50f06ab43746c197.tar.gz
chromium_src-27f5d779cac0af5721fc4d9b50f06ab43746c197.tar.bz2
Fix double-initialization of CComModule.
This should allow ATL to work in all build configurations by dynamically creating a CComModule only if needed. BUG=102736 TEST=None Review URL: http://codereview.chromium.org/8467002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win')
-rw-r--r--ui/base/win/atl_module.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/ui/base/win/atl_module.h b/ui/base/win/atl_module.h
new file mode 100644
index 0000000..3fe3be9
--- /dev/null
+++ b/ui/base/win/atl_module.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_WIN_ATL_MODULE_H_
+#define UI_BASE_WIN_ATL_MODULE_H_
+#pragma once
+
+#include <atlbase.h>
+#include <atlcom.h>
+
+#include "base/basictypes.h"
+
+namespace ui {
+namespace win {
+
+// Ensure that we have exactly one ATL module registered. It's safe to
+// call this more than once. ATL functions will crash if there's no
+// ATL module registered, or if you try to register two of them, so
+// dynamically registering one if needed makes it much easier for us
+// to support different build configurations like multi-dll without
+// worrying about which side of a module boundary each ATL module object
+// belongs on.
+//
+// This function must be implemented in this header file rather than a
+// source file so that it's inlined into the module where it's included,
+// rather than in the "ui" module.
+static void CreateATLModuleIfNeeded() {
+ if (_pAtlModule == NULL) {
+ // This creates the module and automatically updates _pAtlModule.
+ CR_DEFINE_STATIC_LOCAL(CComModule, module, ());
+ }
+}
+
+} // namespace win
+} // namespace ui
+
+#endif // UI_BASE_WIN_ATL_MODULE_H_