From 571d4ed2f01c1117237b1a9684ad9b1d1ad8963a Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 26 Sep 2022 17:07:52 -0400 Subject: DebugInfo: make parseInfo have a progress callback This will enable us to have progress bars and cancellation of debuginfo application --- binaryview.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 8c6080d0..e8c080df 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -3494,12 +3494,6 @@ void BinaryView::DefineUserType(const QualifiedName& name, Ref type) } -struct ProgressCallback -{ - std::function func; -}; - - void BinaryView::DefineTypes(const vector>& types, std::function progress) { BNQualifiedNameTypeAndId* apiTypes = new BNQualifiedNameTypeAndId[types.size()]; @@ -3510,14 +3504,9 @@ void BinaryView::DefineTypes(const vector>& t apiTypes[i].id = BNAllocString(types[i].first.c_str()); } - ProgressCallback cb; - cb.func = progress; - BNDefineAnalysisTypes(m_object, apiTypes, types.size(), [](void* ctxt, size_t cur, size_t total) { - ProgressCallback* cb = (ProgressCallback*)ctxt; - if (cb->func) - return cb->func(cur, total); - return true; - }, &cb); + ProgressContext cb; + cb.callback = progress; + BNDefineAnalysisTypes(m_object, apiTypes, types.size(), ProgressCallback, &cb); for (size_t i = 0; i < types.size(); i++) { @@ -3537,14 +3526,9 @@ void BinaryView::DefineUserTypes(const vector& types, std: apiTypes[i].type = types[i].type->GetObject(); } - ProgressCallback cb; - cb.func = progress; - BNDefineUserAnalysisTypes(m_object, apiTypes, types.size(), [](void* ctxt, size_t cur, size_t total) { - ProgressCallback* cb = (ProgressCallback*)ctxt; - if (cb->func) - return cb->func(cur, total); - return true; - }, &cb); + ProgressContext cb; + cb.callback = progress; + BNDefineUserAnalysisTypes(m_object, apiTypes, types.size(), ProgressCallback, &cb); for (size_t i = 0; i < types.size(); i++) { -- cgit v1.3.1