From 90711f234e3b780a5cb4b9544fd04e9d51020f3b Mon Sep 17 00:00:00 2001 From: Douglas Fuller Date: Tue, 6 Oct 2020 17:50:52 -0400 Subject: [PATCH] Geary.App.FillWindowOperation: detect stale FillWindowOperations When a user types in the search box, there may still be oustanding FillWindowOperations queued on previous instances of SearchFolder from previous keystrokes. This can result in a FillWindowOperation with a stale value of ConversationMonitor.window_lowest from a previous search executing on the current one. Detect this and return immediately. Fixes: #838 --- .../app-fill-window-operation.vala | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/engine/app/conversation-monitor/app-fill-window-operation.vala b/src/engine/app/conversation-monitor/app-fill-window-operation.vala index 9f34797b..a7ca8b8c 100644 --- a/src/engine/app/conversation-monitor/app-fill-window-operation.vala +++ b/src/engine/app/conversation-monitor/app-fill-window-operation.vala @@ -37,9 +37,16 @@ private class Geary.App.FillWindowOperation : ConversationOperation { num_to_load = MAX_FILL_COUNT; } - int loaded = yield this.monitor.load_by_id_async( - this.monitor.window_lowest, num_to_load, LOCAL_ONLY - ); + int loaded = 0; + + try { + loaded = yield this.monitor.load_by_id_async( + this.monitor.window_lowest, num_to_load, LOCAL_ONLY + ); + } catch (EngineError.NOT_FOUND err) { + debug("Stale FillWindowOperation: %s", err.message); + return; + } debug( "Filled %d of %d locally, window: %d, total: %d", @@ -61,9 +68,14 @@ private class Geary.App.FillWindowOperation : ConversationOperation { // Load the max amount if going to the trouble of talking // to the remote. num_to_load = MAX_FILL_COUNT; - loaded = yield this.monitor.load_by_id_async( - this.monitor.window_lowest, num_to_load, FORCE_UPDATE - ); + try { + loaded = yield this.monitor.load_by_id_async( + this.monitor.window_lowest, num_to_load, FORCE_UPDATE + ); + } catch (EngineError.NOT_FOUND err) { + debug("Stale FillWindowOperation: %s", err.message); + return; + } debug( "Filled %d of %d from the remote, window: %d, total: %d",