elementary / elementary/calendar
Error in calmodel.calclient_is_readonly for disabled sources
- Dominant language
- Vala
- Stars
- 136
- Forks
- 42
- Avg merge
- 8h 33m
- Merged PRs (30d)
- 3
Description
## Prerequisites
- [x] I have searched open and closed issues for duplicates.
## Describe the bug
When constructing a new `CalendarButton`, it iterates through the whole list of available sources. When it finds one that has been disabled (using the checkbox in the calendars list), it produces the following error:
```
** (io.elementary.calendar:5816): CRITICAL **: 13:35:05.171: CalendarModel.vala:128: No calendar client was found
```
### To Reproduce
This requires editing the code, but it's the only way I can think of to show the issue.
Steps to reproduce the behavior:
1. Uncheck a calendar from the list
2. Add a new line to `CalendarButton` line 50 (between `foreach` and `if`: `debug (@"CalendarButton source: $(src.display_name)");`
3. Run Calendar with debug messages enabled (`G_MESSAGES_DEBUG=all`)
4. The name of the calendar you just unchecked will appear immediately before the error shown above
I've done some digging to figure out exactly why this happens, but not sure how to fix it.
The code that produces this error is
```vala
foreach (var src in registry.list_sources (E.SOURCE_EXTENSION_CALENDAR)) {
debug (@"CalendarButton source: $(src.display_name)");
if (src.writable == true && src.enabled == true && calmodel.calclient_is_readonly (src) == false) { // HERE
sources.append (src);
}
}
```
I believe that the actual problem is the way we handle "disabling" calendars. `calmodel.calclient_is_readonly` tries to get each calendar from the `source_client` list. When I uncheck/remove a calendar, it removes that client from this list. So when the foreach in `CalendarButton` goes to check `calmodel.calclient_is_readonly`, it comes back with a null element from the list. It interprets this as a critical error in line 128. So the issue must be that when we disable a calendar, it doesn't get removed from the registry, but does get removed from our records (`source_client`).
## Platform Information

- [x] I'm using the latest version from git that I've manually compiled
- [ ] I'm using the latest released stable version
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/92263823-error-in-calmodel-calclient_is_readonly-for-disabled-sources?utm_campaign=plugin&utm_content=tracker%2F60388692&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F60388692&utm_medium=issues&utm_source=github).
Contributor guide
Assessment
This issue has not been assessed yet.