aboutsummaryrefslogtreecommitdiff
path: root/swaynag/main.c
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2022-06-05 10:37:17 +0200
committerFurkan Sahin <furkan-dev@proton.me>2022-06-05 10:37:17 +0200
commit18dbc5fbeccd53a7b6e11f6e4ceb5974e39ea8b8 (patch)
tree59f2078a820100496a08952f8fecf5db6dfd339e /swaynag/main.c
parent301d2d21227d50919a8242b4efb5f3400c99288d (diff)
swaynag: move close_button up to fix SIGSEGV
When swaynag_parse_options encounters '--dismiss-button' (or its shorthand '-s'), it sets the text of the first button in the swaynag.buttons list, which is expected to exist and to be the dismiss button, to the one passed by the user. Commit 38288c3916d3d9f33771c220ae307d32e8a208e8 ("swaynag: statically allocate button_close, and move declaration") moved the list initialization to after swaynag_parse_options is called which made that code fail. For example, the command 'swaynag --dismiss-button Dismiss' crashes and 'swaynag --message Message --button Yes "" --dismiss-button Dismiss' shows the wrong buttons. Move it back to before swaynag_parse_options is called.
Diffstat (limited to 'swaynag/main.c')
-rw-r--r--swaynag/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/swaynag/main.c b/swaynag/main.c
index 56e4950b..2ce37831 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -29,6 +29,11 @@ int main(int argc, char **argv) {
wl_list_init(&swaynag.outputs);
wl_list_init(&swaynag.seats);
+ struct swaynag_button button_close = { 0 };
+ button_close.text = strdup("X");
+ button_close.type = SWAYNAG_ACTION_DISMISS;
+ list_add(swaynag.buttons, &button_close);
+
char *config_path = NULL;
bool debug = false;
status = swaynag_parse_options(argc, argv, NULL, NULL, NULL,
@@ -85,11 +90,6 @@ int main(int argc, char **argv) {
swaynag_types_free(types);
- struct swaynag_button button_close = { 0 };
- button_close.text = strdup("X");
- button_close.type = SWAYNAG_ACTION_DISMISS;
- list_add(swaynag.buttons, &button_close);
-
if (swaynag.details.message) {
list_add(swaynag.buttons, &swaynag.details.button_details);
}