This allows to get rid of the last remaining Ptr<T>::addref calls.
//! the full constructor that opens file storage for reading or writing
CV_WRAP FileStorage(const String& source, int flags, const String& encoding=String());
//! the constructor that takes pointer to the C FileStorage structure
- FileStorage(CvFileStorage* fs);
+ FileStorage(CvFileStorage* fs, bool owning=true);
//! the destructor. calls release()
virtual ~FileStorage();
open( filename, flags, encoding );
}
-FileStorage::FileStorage(CvFileStorage* _fs)
+FileStorage::FileStorage(CvFileStorage* _fs, bool owning)
{
- fs = Ptr<CvFileStorage>(_fs);
+ if (owning) fs.reset(_fs);
+ else fs = Ptr<CvFileStorage>(Ptr<CvFileStorage>(), _fs);
+
state = _fs ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED;
}
void CvEM::write( CvFileStorage* _fs, const char* name ) const
{
- FileStorage fs = _fs;
+ FileStorage fs(_fs, false);
if(name)
fs << name << "{";
emObj.write(fs);
if(name)
fs << "}";
- fs.fs.obj = 0;
}
double CvEM::calcLikelihood( const Mat &input_sample ) const
{
if(ptr && _fs)
{
- FileStorage fs(_fs);
- fs.fs.addref();
+ FileStorage fs(_fs, false);
((const _ClsName*)ptr)->write(fs, String(name));
}
}