Skip to content

Commit

Permalink
removed context as enable_shared_from_this
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Dec 11, 2023
1 parent bfc06a5 commit 3a0121b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ namespace librealsense {
}


void context::create_factories()
void context::create_factories( std::shared_ptr< context > const & sptr )
{
// This can only get called once the constructor is done:
auto sptr = shared_from_this();

_factories.push_back( std::make_shared< backend_device_factory >(
sptr,
[this]( std::vector< std::shared_ptr< device_info > > const & removed,
Expand All @@ -93,9 +90,9 @@ namespace librealsense {

/*static*/ std::shared_ptr< context > context::make( json const & settings )
{
std::shared_ptr< context > ctx( new context( settings ) );
ctx->create_factories();
return ctx;
std::shared_ptr< context > sptr( new context( settings ) );
sptr->create_factories( sptr );
return sptr;
}


Expand Down
4 changes: 2 additions & 2 deletions src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace librealsense
class processing_block_interface;


class context : public std::enable_shared_from_this<context>
class context
{
context( nlohmann::json const & ); // private! use make()

void create_factories();
void create_factories( std::shared_ptr< context > const & sptr );

public:
static std::shared_ptr< context > make( nlohmann::json const & );
Expand Down

0 comments on commit 3a0121b

Please sign in to comment.