From cb69109ccbf6bdc5238c3e58b7402b4c89698e4c Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 8 Sep 2019 03:10:09 +0300 Subject: [PATCH] Add G() debug. GitOrigin-RevId: 0ccc0d43c93186add1119fa2d72e8c669cfa6dd3 --- td/telegram/Global.h | 7 +++++-- td/telegram/SecretChatActor.cpp | 3 ++- td/telegram/logevent/LogEventHelper.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/td/telegram/Global.h b/td/telegram/Global.h index 564dc8e29..a70b592c0 100644 --- a/td/telegram/Global.h +++ b/td/telegram/Global.h @@ -78,6 +78,7 @@ class Global : public ActorContext { LOG_CHECK(td_db_) << close_flag() << " " << file << " " << line; return td_db_.get(); } + void close_all(Promise<> on_finished); void close_and_destroy_all(Promise<> on_finished); @@ -425,10 +426,12 @@ class Global : public ActorContext { void do_close(Promise<> on_finish, bool destroy_flag); }; -inline Global *G() { +#define G() G_impl(__FILE__, __LINE__) + +inline Global *G_impl(const char *file, int line) { ActorContext *context = Scheduler::context(); CHECK(context); - CHECK(context->get_id() == Global::ID); + LOG_CHECK(context->get_id() == Global::ID) << "In " << file << " at " << line; return static_cast(context); } diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index f6f233f3a..67f669cb0 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -39,7 +39,8 @@ #include #include -#define G GLOBAL_SHOULD_NOT_BE_USED_HERE +//#define G GLOBAL_SHOULD_NOT_BE_USED_HERE +#undef G namespace td { diff --git a/td/telegram/logevent/LogEventHelper.h b/td/telegram/logevent/LogEventHelper.h index f286f7b69..f3be27059 100644 --- a/td/telegram/logevent/LogEventHelper.h +++ b/td/telegram/logevent/LogEventHelper.h @@ -22,7 +22,7 @@ namespace td { #define get_erase_logevent_promise(...) get_erase_logevent_promise_impl(__FILE__, __LINE__, __VA_ARGS__) -inline Promise get_erase_logevent_promise_impl(const char *file, int32 line, uint64 logevent_id, +inline Promise get_erase_logevent_promise_impl(const char *file, int line, uint64 logevent_id, Promise promise = Promise()) { if (logevent_id == 0) { return promise;