swaynag: call swaynag_destroy on clean exit

And fix the fallout of the swaynag_destroy having evolved without
being tested:
* wl_display_disconnect was called too early
* `button_close` and `swaynag.details.button_details` needed to be
  heap allocated, since they are added to swaynag.buttons, and all
  entries of swaynag.buttons are freed in swaynag_destroy
* To keep things simpler, disconnect the lifetime of the 'Toggle details'
  button text config setting from the button itself.
This commit is contained in:
Manuel Stoeckl 2023-01-08 09:21:30 -05:00 committed by Simon Zeni
parent 2f2cdd60de
commit 5e73acb431
4 changed files with 19 additions and 18 deletions

View file

@ -483,10 +483,6 @@ void swaynag_run(struct swaynag *swaynag) {
&& wl_display_dispatch(swaynag->display) != -1) {
// This is intentionally left blank
}
if (swaynag->display) {
wl_display_disconnect(swaynag->display);
}
}
void swaynag_destroy(struct swaynag *swaynag) {
@ -501,6 +497,7 @@ void swaynag_destroy(struct swaynag *swaynag) {
}
list_free(swaynag->buttons);
free(swaynag->details.message);
free(swaynag->details.details_text);
free(swaynag->details.button_up.text);
free(swaynag->details.button_down.text);
@ -541,4 +538,8 @@ void swaynag_destroy(struct swaynag *swaynag) {
if (swaynag->shm) {
wl_shm_destroy(swaynag->shm);
}
if (swaynag->display) {
wl_display_disconnect(swaynag->display);
}
}