Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FilterEngine.cpp

Issue 29389580: Issue 1397 - FilterEngine::ForceUpdateCheck crashes when passed a 0 std::function (Closed)
Patch Set: Created March 20, 2017, 2:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/api.js ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp
index 333e13930aa14fce4bc53a26d06488597a0497d9..8c2698d33acfc14a34facdfe4b041190c1e53655 100644
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -499,17 +499,17 @@ void FilterEngine::UpdateAvailable(
}
void FilterEngine::ForceUpdateCheck(
- FilterEngine::UpdateCheckDoneCallback callback)
+ const FilterEngine::UpdateCheckDoneCallback& callback)
{
- std::string eventName = "_updateCheckDone";
- eventName += ++updateCheckId;
-
- jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDone,
- this, eventName, callback, std::placeholders::_1));
-
JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck");
JsValueList params;
- params.push_back(jsEngine->NewValue(eventName));
+ if (callback)
+ {
+ std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId);
+ jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDone,
+ this, eventName, callback, std::placeholders::_1));
+ params.push_back(jsEngine->NewValue(eventName));
+ }
func->Call(params);
}
« no previous file with comments | « lib/api.js ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld