fix: some crashes

This commit is contained in:
Alex
2026-02-24 00:49:03 +01:00
parent a32413a74f
commit ef3d55980e
40 changed files with 216 additions and 103 deletions

View File

@ -59,10 +59,12 @@ UPower::UPower(const std::string& id, const Json::Value& config)
sigc::mem_fun(*this, &UPower::getConn_cb));
// Make UPower client
GError** gErr = NULL;
upClient_ = up_client_new_full(NULL, gErr);
if (upClient_ == NULL)
spdlog::error("Upower. UPower client connection error. {}", (*gErr)->message);
GError* gErr = NULL;
upClient_ = up_client_new_full(NULL, &gErr);
if (upClient_ == NULL) {
spdlog::error("Upower. UPower client connection error. {}", gErr ? gErr->message : "unknown error");
if (gErr) g_error_free(gErr);
}
// Subscribe UPower events
g_signal_connect(upClient_, "device-added", G_CALLBACK(deviceAdded_cb), this);