diff --git a/src/core/generation.cpp b/src/core/generation.cpp index b972f5248..9f2c8604b 100644 --- a/src/core/generation.cpp +++ b/src/core/generation.cpp @@ -198,6 +198,7 @@ void EngineGeneration::setWatchingFiles(bool watching) { } } else { if (this->watcher != nullptr) { + QObject::disconnect(this->watcher, nullptr, this, nullptr); this->watcher->deleteLater(); this->watcher = nullptr; } diff --git a/src/core/persistentprops.hpp b/src/core/persistentprops.hpp index ef4e2bf62..b899b7f8f 100644 --- a/src/core/persistentprops.hpp +++ b/src/core/persistentprops.hpp @@ -6,7 +6,7 @@ #include "reload.hpp" ///! Object that holds properties that can persist across a config reload. -/// PersistentProperties holds properties declated in it across a reload, which is +/// PersistentProperties holds properties declared in it across a reload, which is /// often useful for things like keeping expandable popups open and styling them. /// /// Below is an example of using `PersistentProperties` to keep track of the state diff --git a/src/core/qsmenuanchor.cpp b/src/core/qsmenuanchor.cpp index ded8ad058..b0a19f102 100644 --- a/src/core/qsmenuanchor.cpp +++ b/src/core/qsmenuanchor.cpp @@ -74,6 +74,7 @@ void QsMenuAnchor::onClosed() { this->mOpen = false; if (this->platformMenu) { + QObject::disconnect(this->platformMenu, nullptr, this, nullptr); this->platformMenu->deleteLater(); this->platformMenu = nullptr; } @@ -101,7 +102,12 @@ void QsMenuAnchor::setMenu(QsMenuHandle* menu) { if (menu == this->mMenu) return; if (this->mMenu != nullptr) { - if (this->platformMenu != nullptr) this->platformMenu->deleteLater(); + if (this->platformMenu != nullptr) { + QObject::disconnect(this->platformMenu, nullptr, this, nullptr); + this->platformMenu->deleteLater(); + this->platformMenu = nullptr; + } + QObject::disconnect(this->mMenu, nullptr, this, nullptr); } diff --git a/src/io/process.cpp b/src/io/process.cpp index 6055e2c9d..879b6e298 100644 --- a/src/io/process.cpp +++ b/src/io/process.cpp @@ -272,6 +272,7 @@ void Process::onStarted() { } void Process::onFinished(qint32 exitCode, QProcess::ExitStatus exitStatus) { + QObject::disconnect(this->process, nullptr, this, nullptr); this->process->deleteLater(); this->process = nullptr; if (this->mStdoutParser) this->mStdoutParser->streamEnded(this->stdoutBuffer); @@ -290,6 +291,7 @@ void Process::onErrorOccurred(QProcess::ProcessError error) { if (error == QProcess::FailedToStart) { // other cases should be covered by other events qWarning() << "Process failed to start, likely because the binary could not be found. Command:" << this->mCommand; + QObject::disconnect(this->process, nullptr, this, nullptr); this->process->deleteLater(); this->process = nullptr; emit this->runningChanged(); diff --git a/src/io/socket.cpp b/src/io/socket.cpp index 371f6873b..40cfca68a 100644 --- a/src/io/socket.cpp +++ b/src/io/socket.cpp @@ -17,7 +17,11 @@ QS_LOGGING_CATEGORY(logSocket, "quickshell.io.socket", QtWarningMsg); void Socket::setSocket(QLocalSocket* socket) { - if (this->socket != nullptr) this->socket->deleteLater(); + if (this->socket != nullptr) { + QObject::disconnect(this->socket, nullptr, this, nullptr); + this->socket->deleteLater(); + } + this->socket = socket; if (socket != nullptr) { @@ -57,6 +61,7 @@ void Socket::onSocketDisconnected() { qCDebug(logSocket) << "Socket disconnected:" << this; this->connected = false; this->disconnecting = false; + QObject::disconnect(this->socket, nullptr, this, nullptr); this->socket->deleteLater(); this->socket = nullptr; this->buffer.clear(); @@ -191,6 +196,7 @@ void SocketServer::disableServer() { } this->mSockets.clear(); + QObject::disconnect(this->server, nullptr, this, nullptr); this->server->close(); this->server->deleteLater(); this->server = nullptr; diff --git a/src/ipc/ipc.cpp b/src/ipc/ipc.cpp index 9a47c5006..ec258db84 100644 --- a/src/ipc/ipc.cpp +++ b/src/ipc/ipc.cpp @@ -62,6 +62,7 @@ IpcServerConnection::IpcServerConnection(QLocalSocket* socket, IpcServer* server void IpcServerConnection::onDisconnected() { qCInfo(logIpc) << "IPC connection disconnected" << this; + QObject::disconnect(this->socket, nullptr, this, nullptr); this->deleteLater(); } diff --git a/src/services/mpris/watcher.cpp b/src/services/mpris/watcher.cpp index fdfe97add..fdffd7267 100644 --- a/src/services/mpris/watcher.cpp +++ b/src/services/mpris/watcher.cpp @@ -65,8 +65,10 @@ void MprisWatcher::onServiceRegistered(const QString& service) { void MprisWatcher::onServiceUnregistered(const QString& service) { if (auto* player = this->mPlayers.value(service)) { - player->deleteLater(); + QObject::disconnect(player, nullptr, this, nullptr); this->mPlayers.remove(service); + this->readyPlayers.removeObject(player); + player->deleteLater(); qCDebug(logMprisWatcher) << "Unregistered MprisPlayer" << service; } else { qCWarning(logMprisWatcher) << "Got service unregister event for untracked service" << service; diff --git a/src/services/pipewire/connection.cpp b/src/services/pipewire/connection.cpp index c2f505f90..623e54819 100644 --- a/src/services/pipewire/connection.cpp +++ b/src/services/pipewire/connection.cpp @@ -102,6 +102,7 @@ void PwConnection::startSocketWatcher() { void PwConnection::stopSocketWatcher() { if (this->socketWatcher == nullptr) return; + QObject::disconnect(this->socketWatcher, nullptr, this, nullptr); this->socketWatcher->deleteLater(); this->socketWatcher = nullptr; } diff --git a/src/services/polkit/agentimpl.cpp b/src/services/polkit/agentimpl.cpp index 85c62b718..9b4d822f1 100644 --- a/src/services/polkit/agentimpl.cpp +++ b/src/services/polkit/agentimpl.cpp @@ -43,6 +43,8 @@ void PolkitAgentImpl::cancelAllRequests(const QString& reason) { auto* flow = this->bActiveFlow.value(); if (flow) { + QObject::disconnect(flow, nullptr, this, nullptr); + this->bActiveFlow = nullptr; flow->cancelAuthenticationRequest(); flow->deleteLater(); } @@ -169,12 +171,12 @@ void PolkitAgentImpl::finishAuthenticationRequest() { qCDebug(logPolkit) << "finishing authentication request for action" << this->bActiveFlow.value()->actionId(); + QObject::disconnect(this->bActiveFlow.value(), nullptr, this, nullptr); this->bActiveFlow.value()->deleteLater(); + this->bActiveFlow = nullptr; if (!this->queuedRequests.empty()) { this->activateAuthenticationRequest(); - } else { - this->bActiveFlow = nullptr; } } } // namespace qs::service::polkit diff --git a/src/wayland/hyprland/ipc/connection.cpp b/src/wayland/hyprland/ipc/connection.cpp index 627c369f3..9defee87f 100644 --- a/src/wayland/hyprland/ipc/connection.cpp +++ b/src/wayland/hyprland/ipc/connection.cpp @@ -187,8 +187,9 @@ void HyprlandIpc::makeRequest( requestSocket->flush(); }; - auto errorCallback = [=](QLocalSocket::LocalSocketError error) { + auto errorCallback = [=, this](QLocalSocket::LocalSocketError error) { qCWarning(logHyprlandIpc) << "Error making request:" << error << "request:" << request; + QObject::disconnect(requestSocket, nullptr, this, nullptr); requestSocket->deleteLater(); callback(false, {}); };