Skip to content

Commit 66a2293

Browse files
committed
fix: cleanup in Connection destructor
1 parent 59a3ba7 commit 66a2293

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.vs/
55
.DS_Store
66
.idea/
7-
cmake-build-*/
7+
cmake-build-*/
8+
.cache/

src/rpc-connection.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace discord {
3535
class Connection {
3636
private:
3737
Connection() noexcept = default;
38-
~Connection() noexcept = default;
38+
~Connection() noexcept {
39+
this->close();
40+
}
3941

4042
public:
4143
static Connection& get() noexcept {
@@ -142,6 +144,10 @@ namespace discord {
142144
}
143145

144146
void close() {
147+
if (m_state == State::Disconnected) {
148+
return;
149+
}
150+
145151
RPCManager::get().invokeOnDisconnected(toInt(m_lastError), m_lastErrorMessage);
146152
platform::PipeConnection::get().close();
147153
m_state = State::Disconnected;

0 commit comments

Comments
 (0)