void ScreenManager::processFinishDialog() { if (dialogFinished_) { std::lock_guard<std::mutex> guard(inputLock_); // Another dialog may have been pushed before the render, so search for it. Screen *caller = 0; for (size_t i = 0; i < stack_.size(); ++i) { if (stack_[i].screen != dialogFinished_) { continue; } stack_.erase(stack_.begin() + i); // The previous screen was the caller (not necessarily the topmost.) if (i > 0) { caller = stack_[i - 1].screen; } } if (!caller) { ELOG("ERROR: no top screen when finishing dialog"); } else if (caller != topScreen()) { // The caller may get confused if we call dialogFinished() now. WLOG("Skipping non-top dialog when finishing dialog."); } else { caller->dialogFinished(dialogFinished_, dialogResult_); } delete dialogFinished_; dialogFinished_ = 0; } }
void ScreenManager::processFinishDialog() { if (dialogFinished_) { if (stack_.size()) { stack_.pop_back(); } Screen *caller = topScreen(); caller->dialogFinished(dialogFinished_, dialogResult_); delete dialogFinished_; dialogFinished_ = 0; } }
void ScreenManager::processFinishDialog() { if (dialogFinished_) { if (stack_.size()) { stack_.pop_back(); } Screen *caller = topScreen(); if (caller) { caller->dialogFinished(dialogFinished_, dialogResult_); } else { ELOG("ERROR: no top screen when finishing dialog"); } delete dialogFinished_; dialogFinished_ = 0; } }
void ScreenManager::processFinishDialog() { if (dialogFinished_) { std::lock_guard<std::recursive_mutex> guard(inputLock_); // Another dialog may have been pushed before the render, so search for it. Screen *caller = dialogParent(dialogFinished_); for (size_t i = 0; i < stack_.size(); ++i) { if (stack_[i].screen == dialogFinished_) { stack_.erase(stack_.begin() + i); } } if (!caller) { ELOG("ERROR: no top screen when finishing dialog"); } else if (caller != topScreen()) { // The caller may get confused if we call dialogFinished() now. WLOG("Skipping non-top dialog when finishing dialog."); } else { caller->dialogFinished(dialogFinished_, dialogResult_); } delete dialogFinished_; dialogFinished_ = nullptr; } }