File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ class RenderObjectConstructorsHolder
20
20
auto & inst = instance_ ();
21
21
inst.map_ [type] = lambda;
22
22
}
23
+ static void removeConstructorLambda ( const std::type_index& type )
24
+ {
25
+ auto & inst = instance_ ();
26
+ inst.map_ .erase ( type );
27
+ }
23
28
private:
24
29
static RenderObjectConstructorsHolder& instance_ ()
25
30
{
@@ -31,10 +36,16 @@ class RenderObjectConstructorsHolder
31
36
32
37
33
38
RegisterRenderObjectConstructor::RegisterRenderObjectConstructor ( const std::type_index& type, IRenderObjectConstructorLambda lambda )
39
+ : type_( type )
34
40
{
35
41
RenderObjectConstructorsHolder::addConstructorLambda ( type, lambda );
36
42
}
37
43
44
+ RegisterRenderObjectConstructor::~RegisterRenderObjectConstructor ()
45
+ {
46
+ RenderObjectConstructorsHolder::removeConstructorLambda ( type_ );
47
+ }
48
+
38
49
std::unique_ptr<IRenderObject> createRenderObject ( const VisualObject& visObj, const std::type_index& type )
39
50
{
40
51
auto lambda = RenderObjectConstructorsHolder::findConstructorLambda ( type );
Original file line number Diff line number Diff line change @@ -208,6 +208,10 @@ class RegisterRenderObjectConstructor
208
208
{
209
209
public:
210
210
MRMESH_API RegisterRenderObjectConstructor ( const std::type_index& type, IRenderObjectConstructorLambda lambda );
211
+ MRMESH_API ~RegisterRenderObjectConstructor ();
212
+
213
+ private:
214
+ std::type_index type_;
211
215
};
212
216
213
217
#define MR_REGISTER_RENDER_OBJECT_IMPL (objectType, .../* rendObjectType*/ )\
You can’t perform that action at this time.
0 commit comments