feat(slock): intentionally protocol error if lock is destroyed

This commit is contained in:
outfoxxed 2024-02-28 23:32:40 -08:00
parent a255889e5c
commit cdd5729642
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 7 additions and 1 deletions

View file

@ -13,7 +13,12 @@ QSWaylandSessionLock::QSWaylandSessionLock(
this->init(lock); // if isInitialized is false that means we already unlocked.
}
QSWaylandSessionLock::~QSWaylandSessionLock() { this->unlock(); }
QSWaylandSessionLock::~QSWaylandSessionLock() {
if (this->isInitialized()) {
// This will intentionally lock the session if the lock is destroyed without calling unlock.
this->destroy();
}
}
void QSWaylandSessionLock::unlock() {
if (this->isInitialized()) {

View file

@ -36,6 +36,7 @@ bool SessionLockManager::lock() {
bool SessionLockManager::unlock() {
if (!this->isLocked()) return false;
this->mLock->unlock();
auto* lock = this->mLock;
this->mLock = nullptr;
delete lock;