refactor: WlClipboardCollection minor sonar cleanup
This commit is contained in:
parent
ecb03297fd
commit
90e7d475f8
3 changed files with 11 additions and 11 deletions
|
|
@ -258,7 +258,7 @@ bool WlClipboard::empty()
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// Update ownership and cache only if command succeeded
|
// Update ownership and cache only if command succeeded
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
updateOwnership(true);
|
updateOwnership(true);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +291,7 @@ void WlClipboard::add(Format format, const std::string &data)
|
||||||
|
|
||||||
bool success = executeCommandWithInput(args, data);
|
bool success = executeCommandWithInput(args, data);
|
||||||
if (success) {
|
if (success) {
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
updateOwnership(true);
|
updateOwnership(true);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -335,7 +335,7 @@ bool WlClipboard::has(Format format) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
|
|
||||||
// Check cache validity
|
// Check cache validity
|
||||||
Time currentTime = getCurrentTime();
|
Time currentTime = getCurrentTime();
|
||||||
|
|
@ -383,7 +383,7 @@ std::string WlClipboard::get(Format format) const
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
|
|
||||||
// Return cached data if available and valid
|
// Return cached data if available and valid
|
||||||
if (m_cached && m_cachedAvailable[static_cast<int>(format)] && !m_cachedData[static_cast<int>(format)].empty()) {
|
if (m_cached && m_cachedAvailable[static_cast<int>(format)] && !m_cachedData[static_cast<int>(format)].empty()) {
|
||||||
|
|
@ -713,7 +713,7 @@ void WlClipboard::monitorClipboard()
|
||||||
lastTypes = currentTypes;
|
lastTypes = currentTypes;
|
||||||
|
|
||||||
// Clear cache when clipboard changes
|
// Clear cache when clipboard changes
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
const_cast<WlClipboard *>(this)->updateOwnership(false);
|
const_cast<WlClipboard *>(this)->updateOwnership(false);
|
||||||
}
|
}
|
||||||
|
|
@ -750,7 +750,7 @@ void WlClipboard::resetChanged()
|
||||||
m_hasChanged = false;
|
m_hasChanged = false;
|
||||||
|
|
||||||
// Clear cache when resetting change flag to force fresh data retrieval
|
// Clear cache when resetting change flag to force fresh data retrieval
|
||||||
std::lock_guard<std::mutex> lock(m_cacheMutex);
|
std::scoped_lock<std::mutex> lock(m_cacheMutex);
|
||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void WlClipboardCollection::startMonitoring()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &clipboard : m_clipboards) {
|
for (const auto &clipboard : m_clipboards) {
|
||||||
if (clipboard) {
|
if (clipboard) {
|
||||||
clipboard->startMonitoring();
|
clipboard->startMonitoring();
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ void WlClipboardCollection::stopMonitoring()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &clipboard : m_clipboards) {
|
for (const auto &clipboard : m_clipboards) {
|
||||||
if (clipboard) {
|
if (clipboard) {
|
||||||
clipboard->stopMonitoring();
|
clipboard->stopMonitoring();
|
||||||
}
|
}
|
||||||
|
|
@ -80,13 +80,13 @@ void WlClipboardCollection::stopMonitoring()
|
||||||
m_monitoring = false;
|
m_monitoring = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlClipboardCollection::resetChanged()
|
void WlClipboardCollection::resetChanged() const
|
||||||
{
|
{
|
||||||
if (!m_available) {
|
if (!m_available) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &clipboard : m_clipboards) {
|
for (const auto &clipboard : m_clipboards) {
|
||||||
if (clipboard) {
|
if (clipboard) {
|
||||||
clipboard->resetChanged();
|
clipboard->resetChanged();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public:
|
||||||
void stopMonitoring();
|
void stopMonitoring();
|
||||||
|
|
||||||
//! Reset change detection
|
//! Reset change detection
|
||||||
void resetChanged();
|
void resetChanged() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Initialize clipboard backends
|
//! Initialize clipboard backends
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue