================
@@ -40,7 +40,17 @@ SBProgress::~SBProgress() = default;
 void SBProgress::Increment(uint64_t amount, const char *description) {
   LLDB_INSTRUMENT_VA(amount, description);
 
+  if (!m_opaque_up)
+    return;
+
   m_opaque_up->Increment(amount, description);
 }
 
+void SBProgress::Finalize() {
+  if (!m_opaque_up)
+    return;
+
+  m_opaque_up.reset();
----------------
clayborg wrote:

no need to check m_opaque_up here, just call `m_opaque_up.reset();`. If it is 
empty already, it will do nothing. Also add a comment here to explain what is 
going on:
```
// The lldb_private::Progress object is designed to be RAII and send the end 
progress
// event when it gets destroyed. So force our contained object to be destroyed 
and 
// send the progress end event. Clearing this object also allows all other 
methods to 
// quickly return without doing any work if they are called after this method.
m_opaque_up.reset();
```

https://github.com/llvm/llvm-project/pull/128966
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to