From cc4877d0da83eb516059aaed4994100fe015718b Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 12 Dec 2018 20:02:50 +0300 Subject: [PATCH] Fix names of MultiPromiseActor. GitOrigin-RevId: 2efcb2dab1578b0b6deb08f70a7db096daadb4aa --- td/telegram/TopDialogManager.cpp | 2 +- tdactor/td/actor/MultiPromise.cpp | 3 +++ tdactor/td/actor/MultiPromise.h | 6 +++--- tdutils/td/utils/tl_storers.h | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/td/telegram/TopDialogManager.cpp b/td/telegram/TopDialogManager.cpp index 8fa9d5b8..f84496e9 100644 --- a/td/telegram/TopDialogManager.cpp +++ b/td/telegram/TopDialogManager.cpp @@ -524,7 +524,7 @@ void TopDialogManager::init() { void TopDialogManager::on_first_sync() { was_first_sync_ = true; - if (G()->td().get_actor_unsafe()->auth_manager_->is_bot()) { + if (!G()->close_flag() && G()->td().get_actor_unsafe()->auth_manager_->is_bot()) { is_active_ = false; init(); } diff --git a/tdactor/td/actor/MultiPromise.cpp b/tdactor/td/actor/MultiPromise.cpp index 3335cd3f..7a2719b5 100644 --- a/tdactor/td/actor/MultiPromise.cpp +++ b/tdactor/td/actor/MultiPromise.cpp @@ -13,6 +13,9 @@ void MultiPromiseActor::add_promise(Promise &&promise) { } Promise MultiPromiseActor::get_promise() { + if (empty()) { + register_actor(name_, this).release(); + } CHECK(!promises_.empty()); PromiseActor promise; diff --git a/tdactor/td/actor/MultiPromise.h b/tdactor/td/actor/MultiPromise.h index c7380382..a1d4a1c4 100644 --- a/tdactor/td/actor/MultiPromise.h +++ b/tdactor/td/actor/MultiPromise.h @@ -60,8 +60,7 @@ class MultiPromiseActor final : public Actor , public MultiPromiseInterface { public: - MultiPromiseActor(Slice name) { - register_actor(name, this).release(); + explicit MultiPromiseActor(string name) : name_(std::move(name)) { } void add_promise(Promise &&promise) override; @@ -75,6 +74,7 @@ class MultiPromiseActor final private: void set_result(Result &&result); + string name_; vector> promises_; // promises waiting for result vector> futures_; // futures waiting for result of the queries size_t received_results_ = 0; @@ -96,7 +96,7 @@ class MultiPromiseActorSafe : public MultiPromiseInterface { Promise get_promise() override; void set_ignore_errors(bool ignore_errors) override; size_t promise_count() const override; - explicit MultiPromiseActorSafe(Slice name) : multi_promise_(make_unique(name)) { + explicit MultiPromiseActorSafe(string name) : multi_promise_(td::make_unique(std::move(name))) { } MultiPromiseActorSafe(const MultiPromiseActorSafe &other) = delete; MultiPromiseActorSafe &operator=(const MultiPromiseActorSafe &other) = delete; diff --git a/tdutils/td/utils/tl_storers.h b/tdutils/td/utils/tl_storers.h index 5a0147c6..1411b40c 100644 --- a/tdutils/td/utils/tl_storers.h +++ b/tdutils/td/utils/tl_storers.h @@ -227,7 +227,7 @@ class TlStorerToString { int b = value[static_cast(i)] & 0xff; result += hex[b >> 4]; result += hex[b & 15]; - if (i != len) { + if (i + 1 != len) { result += ' '; } }