fix assignment operator

This commit is contained in:
Günter Obiltschnig 2020-01-21 19:58:38 +01:00
parent eeb64cc340
commit 2018a698ba

View File

@ -72,13 +72,16 @@ DirectoryIterator::~DirectoryIterator()
DirectoryIterator& DirectoryIterator::operator = (const DirectoryIterator& it)
{
if (_pImpl) _pImpl->release();
_pImpl = it._pImpl;
if (_pImpl)
if (&it != this)
{
_pImpl->duplicate();
_path = it._path;
_file = _path;
if (_pImpl) _pImpl->release();
_pImpl = it._pImpl;
if (_pImpl)
{
_pImpl->duplicate();
_path = it._path;
_file = _path;
}
}
return *this;
}