【发布时间】:2019-02-24 13:28:30
【问题描述】:
我想在我的构造函数中调用一些代码
connect(self() , 0 , filter , 0);
connect(filter , 0 , self() , 0);
但我得到异常
在抛出 'boost::exception_detail::clone_impl >' 的实例后调用终止
下一个
my_filter::sptr
my_filter::make(unsigned int interpolation,
unsigned int decimation) {
auto ptr = gnuradio::get_initial_sptr(new my_filter
(interpolation, decimation));
ptr->wire();
return ptr;
}
和方法线
void my_filter::wire() {
connect(self(), 0, resampler, 0);
connect(resampler, 0, self(), 0);
}
但我得到错误
Terminate called after throwing an instance of 'std::invalid_argument'
what(): sptr_magic: invalid pointer!
what(): tr1::bad_weak_ptr
我该如何改进?
【问题讨论】:
-
我们需要一个minimal reproducible example,但大概在您调用
self()时,self()包含的任何对象当前都不属于std::shared_ptr