First implementation of non-UI-locking callbacks.

Sorting plugins no longer freezes the UI. Part of #246.
This commit is contained in:
WrinklyNinja
2014-08-26 20:28:10 +01:00
parent 866e9a2b90
commit 81da6c4d0b
2 changed files with 10 additions and 8 deletions
+6 -6
View File
@@ -33,6 +33,8 @@
#include <include/cef_app.h>
#include <include/cef_runnable.h>
#include <include/cef_task.h>
#include <include/base/cef_bind.h>
#include "include/wrapper/cef_closure_task.h"
#include <boost/log/trivial.hpp>
#include <boost/filesystem.hpp>
@@ -68,7 +70,6 @@ namespace loot {
const CefString& request,
bool persistent,
CefRefPtr<Callback> callback) {
if (request == "openReadme") {
try {
OpenReadme();
@@ -179,8 +180,7 @@ namespace loot {
return true;
}
else if (request == "sortPlugins") {
callback->Success(SortPlugins());
return true;
return CefPostTask(TID_FILE, base::Bind(&Handler::SortPlugins, base::Unretained(this), callback));
}
else if (request == "getInitErrors") {
YAML::Node node(g_app_state.InitErrors());
@@ -843,7 +843,7 @@ namespace loot {
return "[]";
}
std::string Handler::SortPlugins() {
void Handler::SortPlugins(CefRefPtr<CefMessageRouterBrowserSide::Callback> callback) {
//Set language.
unsigned int language;
if (g_app_state.GetSettings()["language"])
@@ -870,9 +870,9 @@ namespace loot {
}
if (node.size() > 0)
return JSON::stringify(node);
callback->Success(JSON::stringify(node));
else
return "null";
callback->Success("null");
}
YAML::Node Handler::GenerateDerivedMetadata(const Plugin& file, const Plugin& masterlist, const Plugin& userlist) {
+4 -2
View File
@@ -59,7 +59,7 @@ namespace loot {
std::string GetGameData();
std::string UpdateMasterlist();
std::string ClearAllMetadata();
std::string SortPlugins();
void SortPlugins(CefRefPtr<Callback> callback);
// Handle queries with input arguments.
bool HandleComplexQuery(CefRefPtr<CefBrowser> browser, YAML::Node& request,
@@ -75,7 +75,9 @@ namespace loot {
YAML::Node Handler::GenerateDerivedMetadata(const std::string& pluginName);
YAML::Node Handler::GenerateDerivedMetadata(const Plugin& file, const Plugin& masterlist, const Plugin& userlist);
void CopyToClipboard(const std::string& text);
void CopyToClipboard(const std::string& text);
private:
IMPLEMENT_REFCOUNTING(Handler);
};
class LootHandler : public CefClient,