-
- /* g_debug ("DEBUG: %s: Searching account %s",
- __FUNCTION__, tny_account_get_name (account)); */
- res = modest_search_account (account, search);
-
- if (res != NULL) {
-
- if (hits == NULL) {
- hits = res;
- } else {
- hits = g_list_concat (hits, res);
+ if (account) {
+ /* g_debug ("DEBUG: %s: Searching account %s",
+ __FUNCTION__, tny_account_get_name (account)); */
+
+ /* Give the account time to go online if necessary,
+ * for instance if this is immediately after startup,
+ * after D-Bus activation: */
+ modest_platform_check_and_wait_for_account_is_online (account);
+
+ /* Search: */
+ res = modest_search_account (account, search);
+
+ if (res != NULL) {
+ if (hits == NULL) {
+ hits = res;
+ } else {
+ hits = g_list_concat (hits, res);
+ }