Skip to content

Commit d79e29b

Browse files
Series::close(): be a bit cleaner with resource cleanup (#1840)
1 parent 258ef68 commit d79e29b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Series.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,10 +3280,12 @@ namespace internal
32803280
if (this->m_sharedStatefulIterator)
32813281
{
32823282
this->m_sharedStatefulIterator->close();
3283+
this->m_sharedStatefulIterator.reset();
32833284
}
32843285
Series impl;
32853286
impl.setData({this, [](auto const *) {}});
3286-
if (auto IOHandler = impl.IOHandler(); IOHandler &&
3287+
auto IOHandler = impl.IOHandler();
3288+
if (IOHandler &&
32873289
/*
32883290
* Scenario: A user calls `Series::flush()` but does not check for
32893291
* thrown exceptions. The exception will propagate further up,
@@ -3317,7 +3319,7 @@ namespace internal
33173319
// This releases the openPMD hierarchy
33183320
iterations.container().clear();
33193321
// Release the IO Handler
3320-
if (operator*().m_writable.IOHandler)
3322+
if (IOHandler)
33213323
{
33223324
*operator*().m_writable.IOHandler = std::nullopt;
33233325
}

0 commit comments

Comments
 (0)