Commit Graph
28 Commits
Author SHA1 Message Date
Alex 02c20cf339 Merge remote-tracking branch 'origin/master' into agd/ignore-tray-applets
# Conflicts:
#	include/modules/sni/tray.hpp
#	src/modules/sni/host.cpp
#	src/modules/sni/tray.cpp
2026-07-03 22:40:04 +02:00
Alex 5181f84648 fix(sni): prevent use-after-free and infinite retry in Host proxy retry
Store the retry timeout connection in a Host member and disconnect it in
~Host, so a Host destroyed within the retry window no longer invokes the
timeout callback on freed memory. Cap the retries (MAX_RETRIES) so a
watcher that never reappears no longer spins forever every 200ms; reset
the counter on success and when the watcher name vanishes.
2026-07-03 21:39:36 +02:00
oqlatulesba3 3315631012 fix(sni): retry Host proxy creation on transient errors
When Host::proxyReady fails to create the SnWatcher proxy (e.g. because
the Watcher has not finished exporting /StatusNotifierWatcher yet), the
cancellable is left set, causing nameAppeared to early-return on every
subsequent event (see the // TODO marker). The Host is then stuck
without a watcher, and the tray module reports
'No such object path /StatusNotifierWatcher' until the bar is fully
restarted.

Clear the cancellable on non-CANCELLED errors and schedule a single
delayed retry of nameAppeared. The guard `watcher_ != nullptr` skips
the retry if a parallel call already succeeded.

Closes #3468
2026-06-02 10:51:05 +03:00
B2krobbery 7e9c46e4d1 fix(sni): use std::make_unique for Item allocation 2026-04-16 18:34:39 +05:30
Austin Horstman 2a748f1a56 fix(sni): delay tray item insertion until proxies are ready
Only add tray widgets after the SNI proxy has finished initializing and the
item has a valid id/category pair.

This also removes invalid items through the host teardown path, refreshes the
tray when item status changes, and avoids calling DBus methods through a null
proxy during early clicks or scroll events.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-08 01:20:15 -06:00
Austin Horstman 4c71b2bf9f perf(memory): optimize C++ string operations to reduce heap fragmentation
- Replaced pass-by-value std::string parameters with const std::string&
or std::string_view to prevent SSO overallocations.

- Refactored static mapping functions in UPower to return
std::string_view instead of constructing std::string literals, enabling
perfect cache locality.

- Optimized string concatenation in hot loops (network IPs, inhibitor
lists, sway window marks) by using std::string::append() and
pre-reserving capacity instead of overloaded operator+ which produces
temporary heap instances.

These optimizations reduce high-frequency memory churn and overall heap
fragmentation within the main rendering loops.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2026-03-02 22:54:07 -06:00
Alex ef3d55980e fix: some crashes 2026-02-24 00:49:08 +01:00
anton 3655d73525 Ignore Tray entries by service name and when dbus properties load 2026-02-08 00:44:14 +00:00
Tamino Bauknecht 68dfd6aa3a scope_guard/modules: Rename scope_guard to ScopeGuard
Using pascal case for the class name keeps it more consistent with the
majority of the other class names.
2023-10-24 17:51:38 +02:00
Tamino Bauknecht dd1de3efbf Revert "Revert "Fix potential memory leaks""
This reverts commit 2d33c20231 and
reapplies various patches for memory leaks.
The reason for the revert was a bug for a maximum duration interval
which caused sleep_for() to cause unpredictable behavior.
2023-10-24 17:51:38 +02:00
Alexis Rouillard 2d33c20231 Revert "Fix potential memory leaks" 2023-10-22 09:44:46 +02:00
Tamino Bauknecht a0b63d6b1e modules: use scope_exit for deletion to make code more robust 2023-10-21 11:51:18 +02:00
Yifei Teng cd49eef229 Partially revert 3af1853260 to fix use-after-free
After upgrading to the latest release of Waybar the bar will crash
whenever I close the laptop lid. After some debugging I believe it is
because the watching added by watch_name is not being correctly canceled
using unwatch_name. After the Tray object and Host object are destroyed,
additional callbacks will become use-after-free.

Looks like commit 3af1853260 removed the
unwatch_name. I'm not sure why it did that, but it seemed dangerous.

Additionally, bus_name_id_ is created by own_name. According to that
function's documentation, the correct inverse operation is unown_name.
2023-06-30 23:25:24 -07:00
Viktar Lukashonak 3af1853260 Tray module cause error g_bus_unwatch_name()
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
2023-06-06 23:02:36 +03:00
Aleksei Bavshin 24a8332b62 fix: adapt to fmt 9.0.0 breaking changes 2022-07-13 22:36:32 -07:00
Alex f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
Michael Swiger 2d80d31527 Fix tray icon scaling on multi-display setups 2021-08-16 23:33:29 -07:00
Alex f592e3d38b Merge branch 'master' into fmt 2019-08-29 11:29:48 +02:00
Jan Beich 712424f9a8 Unbreak build with fmtlib 6.0.0
In file included from ../src/factory.cpp:1:
In file included from ../include/factory.hpp:4:
../include/modules/clock.hpp:5:10: fatal error: 'fmt/time.h' file not found
 #include "fmt/time.h"
          ^~~~~~~~~~~~
In file included from ../src/bar.cpp:4:
In file included from ../include/factory.hpp:4:
In file included from ../include/modules/clock.hpp:3:
In file included from /usr/include/fmt/chrono.h:12:
/usr/include/fmt/locale.h:19:35: error: parameter type 'fmt::v5::internal::buffer' (aka 'basic_buffer<char>') is an abstract class
    const std::locale& loc, buffer<Char>& buf,
                                  ^
/usr/include/spdlog/fmt/bundled/core.h:238:16: note: unimplemented pure virtual method 'grow' in 'basic_buffer'
  virtual void grow(std::size_t capacity) = 0;
               ^
In file included from ../src/modules/sni/host.cpp:3:
/usr/include/fmt/ostream.h:22:9: error: expected member name or ';' after declaration specifiers
  buffer<Char>& buffer_;
  ~~~~~~^
/usr/include/fmt/ostream.h:25:19: error: expected ')'
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
                  ^
/usr/include/fmt/ostream.h:25:12: note: to match this '('
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
           ^
/usr/include/fmt/ostream.h:25:42: error: use of undeclared identifier 'buf'; did you mean 'prettify_handler::buf'?
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
                                         ^~~
                                         prettify_handler::buf
/usr/include/spdlog/fmt/bundled/format-inl.h:551:11: note: 'prettify_handler::buf' declared here
  buffer &buf;
          ^
2019-08-29 01:38:54 +00:00
Aleksei Bavshin 8f9e6c132d fix(network): stack-use-after-return found by address sanitizer
Fixes compilation with clang.
2019-08-27 00:11:40 -07:00
Lucas Lazare 51be97f9aa Adding spdlog 2019-05-18 19:44:45 -04:00
Alex b54160e02f fix(Tray): add item if not exist 2019-05-13 14:27:01 +02:00
Alex 311c34ecbc feat(Bar): handle widget size changes 2019-04-24 12:37:24 +02:00
Alex 6ed8f94dab refactor: format code 2019-04-18 17:52:00 +02:00
Alex 807ef32357 refactor: format && better output management 2019-04-18 17:47:40 +02:00
Alex 346ec68578 refactor: format tray && partial fix for #235 2019-04-17 14:19:04 +02:00
Alexis 0b1b0eb1a7 feat(tray): multiple hosts 2018-11-22 16:20:49 +01:00
Alexis ba79b4d397 refactor(tray): cleanup and fixes 2018-11-22 15:47:23 +01:00