[gnome-software] Fix another race with displaying shell search provider results
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix another race with displaying shell search provider results
- Date: Thu, 9 Oct 2014 14:49:13 +0000 (UTC)
commit 333af2ce842d49fbb10a8bcf4630acffbdfb1531
Author: Kalev Lember <kalevlember gmail com>
Date: Thu Oct 9 16:37:01 2014 +0200
Fix another race with displaying shell search provider results
Another race that caused us to come up with the search view displayed,
instead of the details view.
We were getting the delayed "search-changed" signal callback after
having already switched to the details view. If the computer was fast
enough and managed to launch the details view in 150 ms, then the
"search-changed" signal handler ran after that and caused us to switch
back to the search view.
Fix this by ignoring the next "search-changed" signal.
src/gs-shell.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index eeee649..29279f2 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -69,6 +69,7 @@ struct GsShellPrivate
GtkBuilder *builder;
GtkWindow *main_window;
GQueue *back_entry_stack;
+ gboolean ignore_next_search_changed_signal;
};
G_DEFINE_TYPE_WITH_PRIVATE (GsShell, gs_shell, G_TYPE_OBJECT)
@@ -410,9 +411,16 @@ window_keypress_handler (GtkWidget *window, GdkEvent *event, GsShell *shell)
}
static void
-search_changed_handler (GObject *entry, GsShell *shell) {
+search_changed_handler (GObject *entry, GsShell *shell)
+{
+ GsShellPrivate *priv = shell->priv;
const gchar *text;
+ if (priv->ignore_next_search_changed_signal) {
+ priv->ignore_next_search_changed_signal = FALSE;
+ return;
+ }
+
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (text[0] == '\0' && gs_shell_get_mode (shell) == GS_SHELL_MODE_SEARCH) {
@@ -761,10 +769,13 @@ gs_shell_show_search_result (GsShell *shell, const gchar *id, const gchar *searc
GtkWidget *widget;
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
+
+ /* ignore next "search-changed" signal to avoid getting a callback
+ * after 150 ms and messing up the state */
+ priv->ignore_next_search_changed_signal = TRUE;
gtk_entry_set_text (GTK_ENTRY (widget), search);
- gs_shell_search_set_appid_to_show (priv->shell_search, id);
- gs_shell_search_switch_to (priv->shell_search, search, TRUE);
+ gs_shell_search_set_appid_to_show (priv->shell_search, id);
gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]