Fix leak of ErrorData after Device::ConsumedError
The code to delete this ErrorData* was lost in the error scope
refactor.
Bug: chromium:1002783, chromium:1002888, dawn:153
Change-Id: Iebe13c778079501193b942ebd97a559041516c3d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11320
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp
index fa45063..7bc8011 100644
--- a/src/dawn_native/Device.cpp
+++ b/src/dawn_native/Device.cpp
@@ -98,8 +98,10 @@
mCurrentErrorScope->HandleError(type, message);
}
- void DeviceBase::HandleError(ErrorData* data) {
- mCurrentErrorScope->HandleError(data);
+ void DeviceBase::ConsumeError(ErrorData* error) {
+ ASSERT(error != nullptr);
+ HandleError(error->GetType(), error->GetMessage().c_str());
+ delete error;
}
void DeviceBase::SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata) {
diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h
index 1c3354f..cf69282 100644
--- a/src/dawn_native/Device.h
+++ b/src/dawn_native/Device.h
@@ -47,11 +47,10 @@
virtual ~DeviceBase();
void HandleError(dawn::ErrorType type, const char* message);
- void HandleError(ErrorData* error);
bool ConsumedError(MaybeError maybeError) {
if (DAWN_UNLIKELY(maybeError.IsError())) {
- HandleError(maybeError.AcquireError());
+ ConsumeError(maybeError.AcquireError());
return true;
}
return false;
@@ -237,6 +236,8 @@
void SetDefaultToggles();
+ void ConsumeError(ErrorData* error);
+
AdapterBase* mAdapter = nullptr;
Ref<ErrorScope> mRootErrorScope;
diff --git a/src/dawn_native/ErrorScope.cpp b/src/dawn_native/ErrorScope.cpp
index 812ab69..1758ef7 100644
--- a/src/dawn_native/ErrorScope.cpp
+++ b/src/dawn_native/ErrorScope.cpp
@@ -15,7 +15,6 @@
#include "dawn_native/ErrorScope.h"
#include "common/Assert.h"
-#include "dawn_native/ErrorData.h"
namespace dawn_native {
@@ -50,11 +49,6 @@
HandleErrorImpl(this, type, message);
}
- void ErrorScope::HandleError(ErrorData* error) {
- ASSERT(error != nullptr);
- HandleErrorImpl(this, error->GetType(), error->GetMessage().c_str());
- }
-
// static
void ErrorScope::HandleErrorImpl(ErrorScope* scope, dawn::ErrorType type, const char* message) {
ErrorScope* currentScope = scope;
diff --git a/src/dawn_native/ErrorScope.h b/src/dawn_native/ErrorScope.h
index 9bafcf9..f3218cb 100644
--- a/src/dawn_native/ErrorScope.h
+++ b/src/dawn_native/ErrorScope.h
@@ -23,8 +23,6 @@
namespace dawn_native {
- class ErrorData;
-
// Errors can be recorded into an ErrorScope by calling |HandleError|.
// Because an error scope should not resolve until contained
// commands are complete, calling the callback is deferred until it is destructed.
@@ -47,7 +45,6 @@
ErrorScope* GetParent();
void HandleError(dawn::ErrorType type, const char* message);
- void HandleError(ErrorData* error);
void Destroy();