mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix: check before destroy
This commit is contained in:
parent
0834551161
commit
bb99e6cf5b
@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glibmm/refptr.h>
|
#include <glibmm/refptr.h>
|
||||||
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/cssprovider.h>
|
#include <gtkmm/cssprovider.h>
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
#include <gtkmm/window.h>
|
#include <gtkmm/window.h>
|
||||||
#include <gtkmm/box.h>
|
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include "AModule.hpp"
|
#include "AModule.hpp"
|
||||||
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
||||||
@ -15,10 +15,10 @@ namespace waybar {
|
|||||||
|
|
||||||
class Factory;
|
class Factory;
|
||||||
struct waybar_output {
|
struct waybar_output {
|
||||||
struct wl_output * output;
|
struct wl_output * output = nullptr;
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t wl_name;
|
uint32_t wl_name;
|
||||||
struct zxdg_output_v1 *xdg_output;
|
struct zxdg_output_v1 *xdg_output = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Bar {
|
class Bar {
|
||||||
|
@ -65,8 +65,14 @@ void waybar::Client::handleGlobalRemove(void * data, struct wl_registry * /*re
|
|||||||
client->outputs_.end(),
|
client->outputs_.end(),
|
||||||
[&name](const auto &output) { return output->wl_name == name; });
|
[&name](const auto &output) { return output->wl_name == name; });
|
||||||
if (it != client->outputs_.end()) {
|
if (it != client->outputs_.end()) {
|
||||||
|
if ((*it)->xdg_output != nullptr) {
|
||||||
zxdg_output_v1_destroy((*it)->xdg_output);
|
zxdg_output_v1_destroy((*it)->xdg_output);
|
||||||
|
(*it)->xdg_output = nullptr;
|
||||||
|
}
|
||||||
|
if ((*it)->output != nullptr) {
|
||||||
wl_output_destroy((*it)->output);
|
wl_output_destroy((*it)->output);
|
||||||
|
(*it)->output = nullptr;
|
||||||
|
}
|
||||||
client->outputs_.erase(it);
|
client->outputs_.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,8 +157,14 @@ void waybar::Client::handleName(void * data, struct zxdg_output_v1 * /*xdg_
|
|||||||
output->name = name;
|
output->name = name;
|
||||||
auto configs = client->getOutputConfigs(output);
|
auto configs = client->getOutputConfigs(output);
|
||||||
if (configs.empty()) {
|
if (configs.empty()) {
|
||||||
|
if (output->output != nullptr) {
|
||||||
wl_output_destroy(output->output);
|
wl_output_destroy(output->output);
|
||||||
|
output->output = nullptr;
|
||||||
|
}
|
||||||
|
if (output->xdg_output != nullptr) {
|
||||||
zxdg_output_v1_destroy(output->xdg_output);
|
zxdg_output_v1_destroy(output->xdg_output);
|
||||||
|
output->xdg_output = nullptr;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_display_roundtrip(client->wl_display);
|
wl_display_roundtrip(client->wl_display);
|
||||||
for (const auto &config : configs) {
|
for (const auto &config : configs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user