From 1766a999061650a4ab8ca93f52653c15b0d61393 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Mon, 20 May 2019 01:15:58 +0900 Subject: [PATCH] Changed the registration order of callback --- src/AutoConnectUpdate.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/AutoConnectUpdate.cpp b/src/AutoConnectUpdate.cpp index 7b987a0..b8deff3 100644 --- a/src/AutoConnectUpdate.cpp +++ b/src/AutoConnectUpdate.cpp @@ -87,7 +87,7 @@ AC_HAS_FUNC(onProgress); template typename std::enable_if::value, AutoConnectUpdate::AC_UPDATEDIALOG_t>::type onProgress(T& updater, std::function fn) { updater.onProgress(fn); - AC_DBG("An updater keeps callback\n"); + AC_DBG("Updater keeps callback\n"); return AutoConnectUpdate::UPDATEDIALOG_METER; } @@ -142,6 +142,14 @@ void AutoConnectUpdate::attach(AutoConnect& portal) { _status = UPDATE_IDLE; + // Attach this to the AutoConnectUpdate + portal._update.reset(this); + AC_DBG("AutoConnectUpdate attached\n"); + if (WiFi.status() == WL_CONNECTED) + enable(); + + // Register the callback to inform the update progress + _dialog = AutoConnectUtil::onProgress(Update, std::bind(&AutoConnectUpdate::_inProgress, this, std::placeholders::_1, std::placeholders::_2)); // Adjust the client dialog pattern according to the callback validity // of the UpdateClass. AutoConnectElement* loader = _progress->getElement(String(F("loader"))); @@ -164,15 +172,6 @@ void AutoConnectUpdate::attach(AutoConnect& portal) { inprogress_loader->enable = false; break; } - - // Attach this to the AutoConnectUpdate - portal._update.reset(this); - AC_DBG("AutoConnectUpdate attached\n"); - if (WiFi.status() == WL_CONNECTED) - enable(); - - // Register the callback to inform the update progress - _dialog = AutoConnectUtil::onProgress(Update, std::bind(&AutoConnectUpdate::_inProgress, this, std::placeholders::_1, std::placeholders::_2)); } /**