Skip to content

Commit 17ca29d

Browse files
committed
i3/ipc: replace I3Ipc object on reload
1 parent a721f7d commit 17ca29d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/x11/i3/ipc/listener.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace qs::i3::ipc {
1515

16-
I3IpcListener::~I3IpcListener() { delete this->i3Ipc; }
16+
I3IpcListener::~I3IpcListener() { this->freeI3Ipc(); }
1717

1818
void I3IpcListener::onPostReload() { this->startListening(); }
1919

@@ -27,7 +27,8 @@ void I3IpcListener::setSubscriptions(QList<QString> subscriptions) {
2727
}
2828

2929
void I3IpcListener::startListening() {
30-
if (this->i3Ipc != nullptr || this->mSubscriptions.isEmpty()) return;
30+
this->freeI3Ipc();
31+
if (this->mSubscriptions.isEmpty()) return;
3132

3233
this->i3Ipc = new I3Ipc(this->mSubscriptions);
3334

@@ -40,4 +41,9 @@ void I3IpcListener::startListening() {
4041

4142
void I3IpcListener::receiveEvent(I3IpcEvent* event) { emit this->ipcEvent(event); }
4243

44+
void I3IpcListener::freeI3Ipc() {
45+
delete this->i3Ipc;
46+
this->i3Ipc = nullptr;
47+
}
48+
4349
} // namespace qs::i3::ipc

src/x11/i3/ipc/listener.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class I3IpcListener: public PostReloadHook {
5959
void startListening();
6060
void receiveEvent(I3IpcEvent* event);
6161

62+
void freeI3Ipc();
63+
6264
QList<QString> mSubscriptions;
6365
I3Ipc* i3Ipc = nullptr;
6466
};

0 commit comments

Comments
 (0)