Codebase list cinnamon-menus / 7516e8d
Check for a valid GDesktopAppInfo before calling GDesktopAppInfo methods. Fix retry handling to only apply to new entries. Use g_timeout_add instead of g_idle_add for change signal accumulation. The process creating the menu tree may not necessarily be affected by system activity, and an idle callback (even with low priority) can run pretty much immediately after being set, causing files to be re-read even while changes (potentially) are still being made by another process, occasionally causing some these files to be inaccessible. Using a timeout forces an artificial wait, and (most importantly) accumulation of changes before going thru the work of rebuilding the menu tree. Michael Webster 5 years ago
3 changed file(s) with 49 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
274274 const char *categories_str;
275275
276276 entry_desktop->appinfo = g_desktop_app_info_new_from_filename (entry->path);
277 if (!entry_desktop->appinfo ||
278 !g_app_info_get_name (G_APP_INFO (entry_desktop->appinfo)) ||
279 !g_app_info_get_executable (G_APP_INFO (entry_desktop->appinfo)))
277 if (!G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo))
280278 {
281279 menu_verbose ("Failed to load \"%s\"\n", entry->path);
282280 return DESKTOP_ENTRY_LOAD_FAIL_APPINFO;
572570 desktop_entry_get_name (DesktopEntry *entry)
573571 {
574572 if (entry->type == DESKTOP_ENTRY_DESKTOP)
575 return g_app_info_get_name (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
573 {
574 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
575 return g_app_info_get_name (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
576 }
577
576578 return ((DesktopEntryDirectory*)entry)->name;
577579 }
578580
580582 desktop_entry_get_generic_name (DesktopEntry *entry)
581583 {
582584 if (entry->type == DESKTOP_ENTRY_DESKTOP)
583 return g_desktop_app_info_get_generic_name (((DesktopEntryDesktop*)entry)->appinfo);
585 {
586 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
587 return g_desktop_app_info_get_generic_name (((DesktopEntryDesktop*)entry)->appinfo);
588 }
589
584590 return ((DesktopEntryDirectory*)entry)->generic_name;
585591 }
586592
588594 desktop_entry_get_comment (DesktopEntry *entry)
589595 {
590596 if (entry->type == DESKTOP_ENTRY_DESKTOP)
591 return g_app_info_get_description (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
597 {
598 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
599 return g_app_info_get_description (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
600 }
601
592602 return ((DesktopEntryDirectory*)entry)->comment;
593603 }
594604
596606 desktop_entry_get_icon (DesktopEntry *entry)
597607 {
598608 if (entry->type == DESKTOP_ENTRY_DESKTOP)
599 return g_app_info_get_icon (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
609 {
610 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), NULL);
611 return g_app_info_get_icon (G_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo));
612 }
613
600614 return ((DesktopEntryDirectory*)entry)->icon;
601615 }
602616
604618 desktop_entry_get_no_display (DesktopEntry *entry)
605619 {
606620 if (entry->type == DESKTOP_ENTRY_DESKTOP)
607 return g_desktop_app_info_get_nodisplay (((DesktopEntryDesktop*)entry)->appinfo);
621 {
622 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), FALSE);
623 return g_desktop_app_info_get_nodisplay (((DesktopEntryDesktop*)entry)->appinfo);
624 }
625
608626 return ((DesktopEntryDirectory*)entry)->nodisplay;
609627 }
610628
612630 desktop_entry_get_hidden (DesktopEntry *entry)
613631 {
614632 if (entry->type == DESKTOP_ENTRY_DESKTOP)
615 return g_desktop_app_info_get_is_hidden (((DesktopEntryDesktop*)entry)->appinfo);
633 {
634 g_return_val_if_fail (G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo), FALSE);
635 return g_desktop_app_info_get_is_hidden (((DesktopEntryDesktop*)entry)->appinfo);
636 }
637
616638 return ((DesktopEntryDirectory*)entry)->hidden;
617639 }
618640
352352 if (strcmp (desktop_entry_get_basename (tmp->data), basename) == 0)
353353 {
354354 if (!desktop_entry_reload (tmp->data))
355 {
356 dir->entries = g_slist_delete_link (dir->entries, tmp);
357 }
355 {
356 dir->entries = g_slist_delete_link (dir->entries, tmp);
357 }
358358
359359 return TRUE;
360360 }
362362 tmp = tmp->next;
363363 }
364364
365 return cached_dir_add_entry (dir, basename, path);
365 return FALSE;
366366 }
367367
368368 static gboolean
519519 cached_dir_queue_monitor_event (dir->parent);
520520 }
521521
522 if (monitors_idle_handler == 0)
523 {
524 monitors_idle_handler = g_idle_add ((GSourceFunc) emit_monitors_in_idle, NULL);
525 }
522 if (monitors_idle_handler > 0)
523 {
524 g_source_remove (monitors_idle_handler);
525 }
526
527 monitors_idle_handler = g_timeout_add (100, (GSourceFunc) emit_monitors_in_idle, NULL);
526528 }
527529
528530 static void
549551 switch (event)
550552 {
551553 case MENU_MONITOR_EVENT_CREATED:
554 handled = cached_dir_add_entry (dir, basename, path);
555 break;
552556 case MENU_MONITOR_EVENT_CHANGED:
553557 handled = cached_dir_update_entry (dir, basename, path);
554558 break;
145145 {
146146 pending_events = g_slist_append (pending_events, event_info);
147147
148 if (events_idle_handler == 0)
149 {
150 events_idle_handler = g_idle_add ((GSourceFunc) emit_events_in_idle, NULL);
151 }
148 if (events_idle_handler > 0)
149 {
150 g_source_remove (events_idle_handler);
151 }
152
153 events_idle_handler = g_timeout_add (100, (GSourceFunc) emit_events_in_idle, NULL);
152154 }
153155
154156 static inline char *