Fix contract violation in shutdown with webview.

This commit is contained in:
John Preston 2021-04-13 16:52:40 +04:00
parent e52f947f98
commit 34c5ce16d0
4 changed files with 16 additions and 1 deletions

View File

@ -63,6 +63,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_domain.h"
#include "storage/storage_databases.h"
#include "storage/localstorage.h"
#include "payments/payments_checkout_process.h"
#include "export/export_manager.h"
#include "window/window_session_controller.h"
#include "window/window_controller.h"
@ -149,6 +150,15 @@ Application::~Application() {
_window = nullptr;
_mediaView = nullptr;
_notifications->clearAllFast();
// We must manually destroy all windows before going further.
// DestroyWindow on Windows (at least with an active WebView) enters
// event loop and invoke scheduled crl::on_main callbacks.
//
// For example Domain::removeRedundantAccounts() is called from
// Domain::finish() and there is a violation on Ensures(started()).
Payments::CheckoutProcess::ClearAll();
_domain->finish();
Local::finish();

View File

@ -112,6 +112,10 @@ bool CheckoutProcess::TakePaymentStarted(
return true;
}
void CheckoutProcess::ClearAll() {
Processes.clear();
}
void CheckoutProcess::RegisterPaymentStart(
not_null<CheckoutProcess*> process) {
const auto i = Processes.find(process->_session);

View File

@ -54,6 +54,7 @@ public:
Fn<void()> reactivate);
[[nodiscard]] static bool TakePaymentStarted(
not_null<const HistoryItem*> item);
static void ClearAll();
CheckoutProcess(
not_null<PeerData*> peer,

View File

@ -501,7 +501,7 @@ bool Panel::createWebview() {
_webview = nullptr;
if (_webviewProgress) {
hideWebviewProgress();
if (!_progress->shown) {
if (_progress && !_progress->shown) {
_progress = nullptr;
}
}