1 |
From fca3e47954fe36687989328ac90cbc6747e4bc4e Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Mon, 14 Mar 2011 10:20:12 +0000 |
4 |
Subject: [PATCH] Related: rhbz#684477 make sure this is thread safe |
5 |
|
6 |
--- |
7 |
basegfx/source/polygon/b2dpolygontools.cxx | 36 +++++++++++++++++---------- |
8 |
1 files changed, 23 insertions(+), 13 deletions(-) |
9 |
|
10 |
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx |
11 |
index 1967e6e..3271314 100644 |
12 |
--- a/basegfx/source/polygon/b2dpolygontools.cxx |
13 |
+++ b/basegfx/source/polygon/b2dpolygontools.cxx |
14 |
@@ -32,6 +32,7 @@ |
15 |
#include <basegfx/polygon/b2dpolygontools.hxx> |
16 |
#include <osl/diagnose.h> |
17 |
#include <rtl/math.hxx> |
18 |
+#include <rtl/instance.hxx> |
19 |
#include <basegfx/polygon/b2dpolygon.hxx> |
20 |
#include <basegfx/polygon/b2dpolypolygon.hxx> |
21 |
#include <basegfx/range/b2drange.hxx> |
22 |
@@ -1836,22 +1837,31 @@ namespace basegfx |
23 |
return aRetval; |
24 |
} |
25 |
|
26 |
- B2DPolygon createUnitPolygon() |
27 |
+ namespace |
28 |
{ |
29 |
- static B2DPolygon aRetval; |
30 |
- |
31 |
- if(!aRetval.count()) |
32 |
+ struct theUnitPolygon : |
33 |
+ public rtl::StaticWithInit<B2DPolygon, theUnitPolygon> |
34 |
{ |
35 |
- aRetval.append( B2DPoint( 0.0, 0.0 ) ); |
36 |
- aRetval.append( B2DPoint( 1.0, 0.0 ) ); |
37 |
- aRetval.append( B2DPoint( 1.0, 1.0 ) ); |
38 |
- aRetval.append( B2DPoint( 0.0, 1.0 ) ); |
39 |
+ B2DPolygon operator () () |
40 |
+ { |
41 |
+ B2DPolygon aRetval; |
42 |
|
43 |
- // close |
44 |
- aRetval.setClosed( true ); |
45 |
- } |
46 |
- |
47 |
- return aRetval; |
48 |
+ aRetval.append( B2DPoint( 0.0, 0.0 ) ); |
49 |
+ aRetval.append( B2DPoint( 1.0, 0.0 ) ); |
50 |
+ aRetval.append( B2DPoint( 1.0, 1.0 ) ); |
51 |
+ aRetval.append( B2DPoint( 0.0, 1.0 ) ); |
52 |
+ |
53 |
+ // close |
54 |
+ aRetval.setClosed( true ); |
55 |
+ |
56 |
+ return aRetval; |
57 |
+ } |
58 |
+ }; |
59 |
+ } |
60 |
+ |
61 |
+ B2DPolygon createUnitPolygon() |
62 |
+ { |
63 |
+ return theUnitPolygon::get(); |
64 |
} |
65 |
|
66 |
B2DPolygon createPolygonFromCircle( const B2DPoint& rCenter, double fRadius ) |
67 |
-- |
68 |
1.7.4.1 |
69 |
|