refactor: remove all mutexes

They are currently not used and slow down the general performance.
This commit is contained in:
Yuhang Zhao 2023-05-19 13:31:20 +08:00
parent ec93740bd7
commit e67a91d668
11 changed files with 8 additions and 137 deletions

View File

@ -23,7 +23,6 @@
*/ */
#include "framelessconfig_p.h" #include "framelessconfig_p.h"
#include <QtCore/qmutex.h>
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#include <QtCore/qsettings.h> #include <QtCore/qsettings.h>
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
@ -81,7 +80,6 @@ static constexpr const auto OptionCount = std::size(OptionsTable);
struct ConfigData struct ConfigData
{ {
QMutex mutex;
bool loaded = false; bool loaded = false;
bool options[OptionCount] = {}; bool options[OptionCount] = {};
bool disableEnvVar = false; bool disableEnvVar = false;
@ -134,7 +132,6 @@ FramelessConfig *FramelessConfig::instance()
void FramelessConfig::reload(const bool force) void FramelessConfig::reload(const bool force)
{ {
const QMutexLocker locker(&g_data()->mutex);
if (g_data()->loaded && !force) { if (g_data()->loaded && !force) {
return; return;
} }
@ -160,25 +157,21 @@ void FramelessConfig::reload(const bool force)
void FramelessConfig::set(const Option option, const bool on) void FramelessConfig::set(const Option option, const bool on)
{ {
const QMutexLocker locker(&g_data()->mutex);
g_data()->options[static_cast<int>(option)] = on; g_data()->options[static_cast<int>(option)] = on;
} }
bool FramelessConfig::isSet(const Option option) const bool FramelessConfig::isSet(const Option option) const
{ {
const QMutexLocker locker(&g_data()->mutex);
return g_data()->options[static_cast<int>(option)]; return g_data()->options[static_cast<int>(option)];
} }
void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on) void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on)
{ {
const QMutexLocker locker(&g_data()->mutex);
g_data()->disableEnvVar = on; g_data()->disableEnvVar = on;
} }
void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on) void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on)
{ {
const QMutexLocker locker(&g_data()->mutex);
g_data()->disableCfgFile = on; g_data()->disableCfgFile = on;
} }

View File

@ -28,7 +28,6 @@
#include "framelessconfig_p.h" #include "framelessconfig_p.h"
#include "framelesshelpercore_global_p.h" #include "framelesshelpercore_global_p.h"
#include "utils.h" #include "utils.h"
#include <QtCore/qmutex.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtGui/qevent.h> #include <QtGui/qevent.h>
#include <QtGui/qwindow.h> #include <QtGui/qwindow.h>
@ -61,7 +60,6 @@ struct QtHelperData
struct QtHelper struct QtHelper
{ {
QMutex mutex;
QHash<WId, QtHelperData> data = {}; QHash<WId, QtHelperData> data = {};
}; };
@ -78,9 +76,7 @@ void FramelessHelperQt::addWindow(FramelessParamsConst params)
return; return;
} }
const WId windowId = params->getWindowId(); const WId windowId = params->getWindowId();
g_qtHelper()->mutex.lock();
if (g_qtHelper()->data.contains(windowId)) { if (g_qtHelper()->data.contains(windowId)) {
g_qtHelper()->mutex.unlock();
return; return;
} }
QtHelperData data = {}; QtHelperData data = {};
@ -89,7 +85,6 @@ void FramelessHelperQt::addWindow(FramelessParamsConst params)
// Give it a parent so that it can be deleted even if we forget to do so. // Give it a parent so that it can be deleted even if we forget to do so.
data.eventFilter = new FramelessHelperQt(window); data.eventFilter = new FramelessHelperQt(window);
g_qtHelper()->data.insert(windowId, data); g_qtHelper()->data.insert(windowId, data);
g_qtHelper()->mutex.unlock();
const auto shouldApplyFramelessFlag = []() -> bool { const auto shouldApplyFramelessFlag = []() -> bool {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
return false; return false;
@ -121,7 +116,6 @@ void FramelessHelperQt::removeWindow(const WId windowId)
if (!windowId) { if (!windowId) {
return; return;
} }
const QMutexLocker locker(&g_qtHelper()->mutex);
if (!g_qtHelper()->data.contains(windowId)) { if (!g_qtHelper()->data.contains(windowId)) {
return; return;
} }
@ -175,13 +169,10 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
} }
const auto window = qobject_cast<QWindow *>(object); const auto window = qobject_cast<QWindow *>(object);
const WId windowId = window->winId(); const WId windowId = window->winId();
g_qtHelper()->mutex.lock();
if (!g_qtHelper()->data.contains(windowId)) { if (!g_qtHelper()->data.contains(windowId)) {
g_qtHelper()->mutex.unlock();
return QObject::eventFilter(object, event); return QObject::eventFilter(object, event);
} }
const QtHelperData data = g_qtHelper()->data.value(windowId); const QtHelperData data = g_qtHelper()->data.value(windowId);
g_qtHelper()->mutex.unlock();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
if (type == QEvent::DevicePixelRatioChange) if (type == QEvent::DevicePixelRatioChange)
#else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0) #else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
@ -208,9 +199,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
switch (type) { switch (type) {
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
if (button == Qt::LeftButton) { if (button == Qt::LeftButton) {
g_qtHelper()->mutex.lock();
g_qtHelper()->data[windowId].leftButtonPressed = true; g_qtHelper()->data[windowId].leftButtonPressed = true;
g_qtHelper()->mutex.unlock();
if (!windowFixedSize) { if (!windowFixedSize) {
const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos); const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos);
if (edges != Qt::Edges{}) { if (edges != Qt::Edges{}) {
@ -223,7 +212,6 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
} break; } break;
case QEvent::MouseButtonRelease: { case QEvent::MouseButtonRelease: {
if (button == Qt::LeftButton) { if (button == Qt::LeftButton) {
const QMutexLocker locker(&g_qtHelper()->mutex);
g_qtHelper()->data[windowId].leftButtonPressed = false; g_qtHelper()->data[windowId].leftButtonPressed = false;
} }
if (button == Qt::RightButton) { if (button == Qt::RightButton) {
@ -251,12 +239,10 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
if (cs == Qt::ArrowCursor) { if (cs == Qt::ArrowCursor) {
if (data.cursorShapeChanged) { if (data.cursorShapeChanged) {
data.params.unsetCursor(); data.params.unsetCursor();
const QMutexLocker locker(&g_qtHelper()->mutex);
g_qtHelper()->data[windowId].cursorShapeChanged = false; g_qtHelper()->data[windowId].cursorShapeChanged = false;
} }
} else { } else {
data.params.setCursor(cs); data.params.setCursor(cs);
const QMutexLocker locker(&g_qtHelper()->mutex);
g_qtHelper()->data[windowId].cursorShapeChanged = true; g_qtHelper()->data[windowId].cursorShapeChanged = true;
} }
} }

View File

@ -31,7 +31,6 @@
#include "framelesshelper_windows.h" #include "framelesshelper_windows.h"
#include "framelesshelpercore_global_p.h" #include "framelesshelpercore_global_p.h"
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qmutex.h>
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include <QtCore/qtimer.h> #include <QtCore/qtimer.h>
@ -105,7 +104,6 @@ struct Win32HelperData
struct Win32Helper struct Win32Helper
{ {
QMutex mutex;
std::unique_ptr<FramelessHelperWin> nativeEventFilter = nullptr; std::unique_ptr<FramelessHelperWin> nativeEventFilter = nullptr;
QHash<WId, Win32HelperData> data = {}; QHash<WId, Win32HelperData> data = {};
QHash<WId, WId> fallbackTitleBarToParentWindowMapping = {}; QHash<WId, WId> fallbackTitleBarToParentWindowMapping = {};
@ -142,18 +140,14 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
const auto windowId = reinterpret_cast<WId>(hWnd); const auto windowId = reinterpret_cast<WId>(hWnd);
g_win32Helper()->mutex.lock();
if (!g_win32Helper()->fallbackTitleBarToParentWindowMapping.contains(windowId)) { if (!g_win32Helper()->fallbackTitleBarToParentWindowMapping.contains(windowId)) {
g_win32Helper()->mutex.unlock();
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
const WId parentWindowId = g_win32Helper()->fallbackTitleBarToParentWindowMapping.value(windowId); const WId parentWindowId = g_win32Helper()->fallbackTitleBarToParentWindowMapping.value(windowId);
if (!g_win32Helper()->data.contains(parentWindowId)) { if (!g_win32Helper()->data.contains(parentWindowId)) {
g_win32Helper()->mutex.unlock();
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
const Win32HelperData data = g_win32Helper()->data.value(parentWindowId); const Win32HelperData data = g_win32Helper()->data.value(parentWindowId);
g_win32Helper()->mutex.unlock();
const auto parentWindowHandle = reinterpret_cast<HWND>(parentWindowId); const auto parentWindowHandle = reinterpret_cast<HWND>(parentWindowId);
// All mouse events: client area mouse events + non-client area mouse events. // All mouse events: client area mouse events + non-client area mouse events.
// Hit-testing event should not be considered as a mouse event. // Hit-testing event should not be considered as a mouse event.
@ -285,7 +279,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
WARNING << Utils::getSystemErrorMessage(kTrackMouseEvent); WARNING << Utils::getSystemErrorMessage(kTrackMouseEvent);
break; break;
} }
const QMutexLocker locker(&g_win32Helper()->mutex);
g_win32Helper()->data[parentWindowId].trackingMouse = true; g_win32Helper()->data[parentWindowId].trackingMouse = true;
} }
} break; } break;
@ -293,7 +286,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
case WM_MOUSELEAVE: { case WM_MOUSELEAVE: {
// When the mouse leaves the drag rect, make sure to dismiss any hover. // When the mouse leaves the drag rect, make sure to dismiss any hover.
releaseButtons(std::nullopt); releaseButtons(std::nullopt);
const QMutexLocker locker(&g_win32Helper()->mutex);
g_win32Helper()->data[parentWindowId].trackingMouse = false; g_win32Helper()->data[parentWindowId].trackingMouse = false;
} break; } break;
// NB: *Shouldn't be forwarding these* when they're not over the caption // NB: *Shouldn't be forwarding these* when they're not over the caption
@ -500,7 +492,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
WARNING << "Failed to re-position the fallback title bar window."; WARNING << "Failed to re-position the fallback title bar window.";
return false; return false;
} }
const QMutexLocker locker(&g_win32Helper()->mutex);
g_win32Helper()->data[parentWindowId].fallbackTitleBarWindowId = fallbackTitleBarWindowId; g_win32Helper()->data[parentWindowId].fallbackTitleBarWindowId = fallbackTitleBarWindowId;
g_win32Helper()->fallbackTitleBarToParentWindowMapping.insert(fallbackTitleBarWindowId, parentWindowId); g_win32Helper()->fallbackTitleBarToParentWindowMapping.insert(fallbackTitleBarWindowId, parentWindowId);
return true; return true;
@ -517,9 +508,7 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
return; return;
} }
const WId windowId = params->getWindowId(); const WId windowId = params->getWindowId();
g_win32Helper()->mutex.lock();
if (g_win32Helper()->data.contains(windowId)) { if (g_win32Helper()->data.contains(windowId)) {
g_win32Helper()->mutex.unlock();
return; return;
} }
Win32HelperData data = {}; Win32HelperData data = {};
@ -530,7 +519,6 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
g_win32Helper()->nativeEventFilter = std::make_unique<FramelessHelperWin>(); g_win32Helper()->nativeEventFilter = std::make_unique<FramelessHelperWin>();
qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get()); qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get());
} }
g_win32Helper()->mutex.unlock();
DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi;
#if 0 #if 0
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint); params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
@ -588,9 +576,7 @@ void FramelessHelperWin::removeWindow(const WId windowId)
if (!windowId) { if (!windowId) {
return; return;
} }
g_win32Helper()->mutex.lock();
if (!g_win32Helper()->data.contains(windowId)) { if (!g_win32Helper()->data.contains(windowId)) {
g_win32Helper()->mutex.unlock();
return; return;
} }
g_win32Helper()->data.remove(windowId); g_win32Helper()->data.remove(windowId);
@ -611,7 +597,6 @@ void FramelessHelperWin::removeWindow(const WId windowId)
} }
++it; ++it;
} }
g_win32Helper()->mutex.unlock();
if (DestroyWindow(reinterpret_cast<HWND>(hwnd)) == FALSE) { if (DestroyWindow(reinterpret_cast<HWND>(hwnd)) == FALSE) {
WARNING << Utils::getSystemErrorMessage(kDestroyWindow); WARNING << Utils::getSystemErrorMessage(kDestroyWindow);
} }
@ -646,13 +631,10 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
return false; return false;
} }
const auto windowId = reinterpret_cast<WId>(hWnd); const auto windowId = reinterpret_cast<WId>(hWnd);
g_win32Helper()->mutex.lock();
if (!g_win32Helper()->data.contains(windowId)) { if (!g_win32Helper()->data.contains(windowId)) {
g_win32Helper()->mutex.unlock();
return false; return false;
} }
const Win32HelperData data = g_win32Helper()->data.value(windowId); const Win32HelperData data = g_win32Helper()->data.value(windowId);
g_win32Helper()->mutex.unlock();
const bool frameBorderVisible = Utils::isWindowFrameBorderVisible(); const bool frameBorderVisible = Utils::isWindowFrameBorderVisible();
const WPARAM wParam = msg->wParam; const WPARAM wParam = msg->wParam;
const LPARAM lParam = msg->lParam; const LPARAM lParam = msg->lParam;
@ -669,7 +651,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
if (Utils::isValidGeometry(data.restoreGeometry) && (data.restoreGeometry == rect)) { if (Utils::isValidGeometry(data.restoreGeometry) && (data.restoreGeometry == rect)) {
return; return;
} }
const QMutexLocker locker(&g_win32Helper()->mutex);
g_win32Helper()->data[windowId].restoreGeometry = rect; g_win32Helper()->data[windowId].restoreGeometry = rect;
}; };
@ -1192,14 +1173,12 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
} }
DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd) DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd)
<< "is" << newDpi << "(was" << oldDpi << ")."; << "is" << newDpi << "(was" << oldDpi << ").";
g_win32Helper()->mutex.lock();
g_win32Helper()->data[windowId].dpi = newDpi; g_win32Helper()->data[windowId].dpi = newDpi;
if (Utils::isValidGeometry(data.restoreGeometry)) { if (Utils::isValidGeometry(data.restoreGeometry)) {
// Update the window size only. The position should not be changed. // Update the window size only. The position should not be changed.
g_win32Helper()->data[windowId].restoreGeometry.setSize( g_win32Helper()->data[windowId].restoreGeometry.setSize(
Utils::rescaleSize(data.restoreGeometry.size(), oldDpi.x, newDpi.x)); Utils::rescaleSize(data.restoreGeometry.size(), oldDpi.x, newDpi.x));
} }
g_win32Helper()->mutex.unlock();
data.params.forceChildrenRepaint(500); data.params.forceChildrenRepaint(500);
} break; } break;
case WM_DWMCOMPOSITIONCHANGED: { case WM_DWMCOMPOSITIONCHANGED: {

View File

@ -26,7 +26,6 @@
#include "framelesshelpercore_global_p.h" #include "framelesshelpercore_global_p.h"
#include "versionnumber_p.h" #include "versionnumber_p.h"
#include "utils.h" #include "utils.h"
#include <QtCore/qmutex.h>
#include <QtCore/qiodevice.h> #include <QtCore/qiodevice.h>
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
@ -148,7 +147,6 @@ FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb)
struct CoreData struct CoreData
{ {
QMutex mutex;
QList<InitializeHookCallback> initHooks = {}; QList<InitializeHookCallback> initHooks = {};
QList<UninitializeHookCallback> uninitHooks = {}; QList<UninitializeHookCallback> uninitHooks = {};
}; };
@ -161,7 +159,6 @@ void registerInitializeHook(const InitializeHookCallback &cb)
if (!cb) { if (!cb) {
return; return;
} }
const QMutexLocker locker(&coreData()->mutex);
coreData()->initHooks.append(cb); coreData()->initHooks.append(cb);
} }
@ -171,7 +168,6 @@ void registerUninitializeHook(const UninitializeHookCallback &cb)
if (!cb) { if (!cb) {
return; return;
} }
const QMutexLocker locker(&coreData()->mutex);
coreData()->uninitHooks.append(cb); coreData()->uninitHooks.append(cb);
} }
@ -232,7 +228,6 @@ void initialize()
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif #endif
const QMutexLocker locker(&coreData()->mutex);
if (!coreData()->initHooks.isEmpty()) { if (!coreData()->initHooks.isEmpty()) {
for (auto &&hook : std::as_const(coreData()->initHooks)) { for (auto &&hook : std::as_const(coreData()->initHooks)) {
Q_ASSERT(hook); Q_ASSERT(hook);
@ -252,7 +247,6 @@ void uninitialize()
} }
uninited = true; uninited = true;
const QMutexLocker locker(&coreData()->mutex);
if (coreData()->uninitHooks.isEmpty()) { if (coreData()->uninitHooks.isEmpty()) {
return; return;
} }

View File

@ -28,7 +28,6 @@
#include "utils.h" #include "utils.h"
#include "framelessconfig_p.h" #include "framelessconfig_p.h"
#include <QtCore/qsysinfo.h> #include <QtCore/qsysinfo.h>
#include <QtCore/qmutex.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtGui/qpixmap.h> #include <QtGui/qpixmap.h>
#include <QtGui/qimage.h> #include <QtGui/qimage.h>
@ -72,7 +71,6 @@ FRAMELESSHELPER_STRING_CONSTANT2(NoiseImageFilePath, ":/org.wangwenx190.Frameles
struct MicaMaterialData struct MicaMaterialData
{ {
QMutex mutex;
QPixmap blurredWallpaper = {}; QPixmap blurredWallpaper = {};
bool graphicsResourcesReady = false; bool graphicsResourcesReady = false;
}; };
@ -507,17 +505,12 @@ const MicaMaterialPrivate *MicaMaterialPrivate::get(const MicaMaterial *q)
void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force) void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force)
{ {
g_micaMaterialData()->mutex.lock();
if (!g_micaMaterialData()->blurredWallpaper.isNull() && !force) { if (!g_micaMaterialData()->blurredWallpaper.isNull() && !force) {
g_micaMaterialData()->mutex.unlock();
return; return;
} }
g_micaMaterialData()->mutex.unlock();
const QSize size = QGuiApplication::primaryScreen()->virtualSize(); const QSize size = QGuiApplication::primaryScreen()->virtualSize();
g_micaMaterialData()->mutex.lock();
g_micaMaterialData()->blurredWallpaper = QPixmap(size); g_micaMaterialData()->blurredWallpaper = QPixmap(size);
g_micaMaterialData()->blurredWallpaper.fill(kDefaultTransparentColor); g_micaMaterialData()->blurredWallpaper.fill(kDefaultTransparentColor);
g_micaMaterialData()->mutex.unlock();
const QString wallpaperFilePath = Utils::getWallpaperFilePath(); const QString wallpaperFilePath = Utils::getWallpaperFilePath();
if (wallpaperFilePath.isEmpty()) { if (wallpaperFilePath.isEmpty()) {
WARNING << "Failed to retrieve the wallpaper file path."; WARNING << "Failed to retrieve the wallpaper file path.";
@ -562,7 +555,6 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force)
const QRect rect = alignedRect(Qt::LeftToRight, Qt::AlignCenter, image.size(), desktopRect); const QRect rect = alignedRect(Qt::LeftToRight, Qt::AlignCenter, image.size(), desktopRect);
bufferPainter.drawImage(rect.topLeft(), image); bufferPainter.drawImage(rect.topLeft(), image);
} }
g_micaMaterialData()->mutex.lock();
QPainter painter(&g_micaMaterialData()->blurredWallpaper); QPainter painter(&g_micaMaterialData()->blurredWallpaper);
painter.setRenderHints(QPainter::Antialiasing | painter.setRenderHints(QPainter::Antialiasing |
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
@ -571,7 +563,6 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force)
#else // !FRAMELESSHELPER_CORE_NO_PRIVATE #else // !FRAMELESSHELPER_CORE_NO_PRIVATE
qt_blurImage(&painter, buffer, kDefaultBlurRadius, true, false); qt_blurImage(&painter, buffer, kDefaultBlurRadius, true, false);
#endif // FRAMELESSHELPER_CORE_NO_PRIVATE #endif // FRAMELESSHELPER_CORE_NO_PRIVATE
g_micaMaterialData()->mutex.unlock();
if (initialized) { if (initialized) {
Q_Q(MicaMaterial); Q_Q(MicaMaterial);
Q_EMIT q->shouldRedraw(); Q_EMIT q->shouldRedraw();
@ -617,9 +608,7 @@ void MicaMaterialPrivate::paint(QPainter *painter, const QSize &size, const QPoi
painter->setRenderHints(QPainter::Antialiasing | painter->setRenderHints(QPainter::Antialiasing |
QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
if (active) { if (active) {
g_micaMaterialData()->mutex.lock();
painter->drawPixmap(originPoint, g_micaMaterialData()->blurredWallpaper, QRect(pos, size)); painter->drawPixmap(originPoint, g_micaMaterialData()->blurredWallpaper, QRect(pos, size));
g_micaMaterialData()->mutex.unlock();
} }
painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
painter->setOpacity(qreal(1)); painter->setOpacity(qreal(1));
@ -661,13 +650,10 @@ void MicaMaterialPrivate::initialize()
void MicaMaterialPrivate::prepareGraphicsResources() void MicaMaterialPrivate::prepareGraphicsResources()
{ {
g_micaMaterialData()->mutex.lock();
if (g_micaMaterialData()->graphicsResourcesReady) { if (g_micaMaterialData()->graphicsResourcesReady) {
g_micaMaterialData()->mutex.unlock();
return; return;
} }
g_micaMaterialData()->graphicsResourcesReady = true; g_micaMaterialData()->graphicsResourcesReady = true;
g_micaMaterialData()->mutex.unlock();
maybeGenerateBlurredWallpaper(); maybeGenerateBlurredWallpaper();
} }

View File

@ -45,7 +45,6 @@
#endif // SYSAPILOADER_QLIBRARY #endif // SYSAPILOADER_QLIBRARY
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qmutex.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#include <QtCore/qvarlengtharray.h> #include <QtCore/qvarlengtharray.h>
@ -74,7 +73,6 @@ static Q_LOGGING_CATEGORY(lcSysApiLoader, "wangwenx190.framelesshelper.core.sysa
struct SysApiLoaderData struct SysApiLoaderData
{ {
QMutex mutex;
QHash<QString, QFunctionPointer> functionCache = {}; QHash<QString, QFunctionPointer> functionCache = {};
}; };
@ -197,7 +195,6 @@ bool SysApiLoader::isAvailable(const QString &library, const QString &function)
return false; return false;
} }
const QString key = generateUniqueKey(library, function); const QString key = generateUniqueKey(library, function);
const QMutexLocker locker(&g_loaderData()->mutex);
if (g_loaderData()->functionCache.contains(key)) { if (g_loaderData()->functionCache.contains(key)) {
if (LoaderDebugFlag) { if (LoaderDebugFlag) {
DEBUG << Q_FUNC_INFO << "Function cache found:" << key; DEBUG << Q_FUNC_INFO << "Function cache found:" << key;
@ -227,7 +224,6 @@ QFunctionPointer SysApiLoader::get(const QString &library, const QString &functi
return nullptr; return nullptr;
} }
const QString key = generateUniqueKey(library, function); const QString key = generateUniqueKey(library, function);
const QMutexLocker locker(&g_loaderData()->mutex);
if (g_loaderData()->functionCache.contains(key)) { if (g_loaderData()->functionCache.contains(key)) {
if (LoaderDebugFlag) { if (LoaderDebugFlag) {
DEBUG << Q_FUNC_INFO << "Function cache found:" << key; DEBUG << Q_FUNC_INFO << "Function cache found:" << key;

View File

@ -28,7 +28,6 @@
#include "framelessconfig_p.h" #include "framelessconfig_p.h"
#include "framelesshelpercore_global_p.h" #include "framelesshelpercore_global_p.h"
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qmutex.h>
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
@ -551,7 +550,6 @@ private:
struct MacUtilsData struct MacUtilsData
{ {
QMutex mutex;
QHash<WId, NSWindowProxy *> hash = {}; QHash<WId, NSWindowProxy *> hash = {};
}; };
@ -577,7 +575,6 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData);
if (!windowId) { if (!windowId) {
return nil; return nil;
} }
const QMutexLocker locker(&g_macUtilsData()->mutex);
if (!g_macUtilsData()->hash.contains(windowId)) { if (!g_macUtilsData()->hash.contains(windowId)) {
QWindow * const qwindow = Utils::findWindow(windowId); QWindow * const qwindow = Utils::findWindow(windowId);
Q_ASSERT(qwindow); Q_ASSERT(qwindow);
@ -592,9 +589,9 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData);
const auto proxy = new NSWindowProxy(qwindow, nswindow); const auto proxy = new NSWindowProxy(qwindow, nswindow);
g_macUtilsData()->hash.insert(windowId, proxy); g_macUtilsData()->hash.insert(windowId, proxy);
} }
#if 0
volatile static const auto hook = []() -> int { volatile static const auto hook = []() -> int {
registerUninitializeHook([](){ registerUninitializeHook([](){
const QMutexLocker locker(&g_macUtilsData()->mutex);
if (g_macUtilsData()->hash.isEmpty()) { if (g_macUtilsData()->hash.isEmpty()) {
return; return;
} }
@ -610,6 +607,7 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData);
return 0; return 0;
}(); }();
Q_UNUSED(hook); Q_UNUSED(hook);
#endif
return g_macUtilsData()->hash.value(windowId); return g_macUtilsData()->hash.value(windowId);
} }
@ -778,7 +776,6 @@ void Utils::removeWindowProxy(const WId windowId)
if (!windowId) { if (!windowId) {
return; return;
} }
const QMutexLocker locker(&g_macUtilsData()->mutex);
if (!g_macUtilsData()->hash.contains(windowId)) { if (!g_macUtilsData()->hash.contains(windowId)) {
return; return;
} }

View File

@ -32,7 +32,6 @@
#include "framelesshelpercore_global_p.h" #include "framelesshelpercore_global_p.h"
#include "versionnumber_p.h" #include "versionnumber_p.h"
#include "scopeguard_p.h" #include "scopeguard_p.h"
#include <QtCore/qmutex.h>
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtGui/qwindow.h> #include <QtGui/qwindow.h>
@ -196,20 +195,12 @@ struct Win32UtilsHelperData
struct Win32UtilsHelper struct Win32UtilsHelper
{ {
QMutex mutex;
QHash<WId, Win32UtilsHelperData> data = {}; QHash<WId, Win32UtilsHelperData> data = {};
QList<WId> micaWindowIds = {};
}; };
Q_GLOBAL_STATIC(Win32UtilsHelper, g_utilsHelper) Q_GLOBAL_STATIC(Win32UtilsHelper, g_utilsHelper)
struct MicaWindowData
{
QMutex mutex;
QList<WId> windowIds = {};
};
Q_GLOBAL_STATIC(MicaWindowData, g_micaData)
struct SYSTEM_METRIC struct SYSTEM_METRIC
{ {
int DPI_96 = 0; // 100%. The scale factor for the device is 1x. int DPI_96 = 0; // 100%. The scale factor for the device is 1x.
@ -498,13 +489,10 @@ static inline void moveWindowToMonitor(const HWND hwnd, const MONITORINFOEXW &ac
return 0; return 0;
} }
const auto windowId = reinterpret_cast<WId>(hWnd); const auto windowId = reinterpret_cast<WId>(hWnd);
g_utilsHelper()->mutex.lock();
if (!g_utilsHelper()->data.contains(windowId)) { if (!g_utilsHelper()->data.contains(windowId)) {
g_utilsHelper()->mutex.unlock();
return DefWindowProcW(hWnd, uMsg, wParam, lParam); return DefWindowProcW(hWnd, uMsg, wParam, lParam);
} }
const Win32UtilsHelperData data = g_utilsHelper()->data.value(windowId); const Win32UtilsHelperData data = g_utilsHelper()->data.value(windowId);
g_utilsHelper()->mutex.unlock();
const auto getNativePosFromMouse = [lParam]() -> QPoint { const auto getNativePosFromMouse = [lParam]() -> QPoint {
return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
}; };
@ -666,9 +654,7 @@ void Utils::updateWindowFrameMargins(const WId windowId, const bool reset)
if (!API_DWM_AVAILABLE(DwmExtendFrameIntoClientArea)) { if (!API_DWM_AVAILABLE(DwmExtendFrameIntoClientArea)) {
return; return;
} }
g_micaData()->mutex.lock(); const bool micaEnabled = g_utilsHelper()->micaWindowIds.contains(windowId);
const bool micaEnabled = g_micaData()->windowIds.contains(windowId);
g_micaData()->mutex.unlock();
const auto margins = [micaEnabled, reset]() -> MARGINS { const auto margins = [micaEnabled, reset]() -> MARGINS {
// To make Mica/Mica Alt work for normal Win32 windows, we have to // To make Mica/Mica Alt work for normal Win32 windows, we have to
// let the window frame extend to the whole window (or disable the // let the window frame extend to the whole window (or disable the
@ -1431,7 +1417,6 @@ void Utils::installSystemMenuHook(const WId windowId, FramelessParamsConst param
if (!windowId || !params) { if (!windowId || !params) {
return; return;
} }
const QMutexLocker locker(&g_utilsHelper()->mutex);
if (g_utilsHelper()->data.contains(windowId)) { if (g_utilsHelper()->data.contains(windowId)) {
return; return;
} }
@ -1461,7 +1446,6 @@ void Utils::uninstallSystemMenuHook(const WId windowId)
if (!windowId) { if (!windowId) {
return; return;
} }
const QMutexLocker locker(&g_utilsHelper()->mutex);
if (!g_utilsHelper()->data.contains(windowId)) { if (!g_utilsHelper()->data.contains(windowId)) {
return; return;
} }
@ -1743,11 +1727,9 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
return false; return false;
} }
const auto restoreWindowFrameMargins = [windowId]() -> void { const auto restoreWindowFrameMargins = [windowId]() -> void {
g_micaData()->mutex.lock(); if (g_utilsHelper()->micaWindowIds.contains(windowId)) {
if (g_micaData()->windowIds.contains(windowId)) { g_utilsHelper()->micaWindowIds.removeAll(windowId);
g_micaData()->windowIds.removeAll(windowId);
} }
g_micaData()->mutex.unlock();
updateWindowFrameMargins(windowId, false); updateWindowFrameMargins(windowId, false);
}; };
const bool preferMicaAlt = (qEnvironmentVariableIntValue("FRAMELESSHELPER_PREFER_MICA_ALT") != 0); const bool preferMicaAlt = (qEnvironmentVariableIntValue("FRAMELESSHELPER_PREFER_MICA_ALT") != 0);
@ -1818,11 +1800,9 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
return result; return result;
} else { } else {
if ((blurMode == BlurMode::Windows_Mica) || (blurMode == BlurMode::Windows_MicaAlt)) { if ((blurMode == BlurMode::Windows_Mica) || (blurMode == BlurMode::Windows_MicaAlt)) {
g_micaData()->mutex.lock(); if (!g_utilsHelper()->micaWindowIds.contains(windowId)) {
if (!g_micaData()->windowIds.contains(windowId)) { g_utilsHelper()->micaWindowIds.append(windowId);
g_micaData()->windowIds.append(windowId);
} }
g_micaData()->mutex.unlock();
// By giving a negative value, DWM will extend the window frame into the whole // By giving a negative value, DWM will extend the window frame into the whole
// client area. We need this step because the Mica material can only be applied // client area. We need this step because the Mica material can only be applied
// to the non-client area of a window. Without this step, you'll get a window // to the non-client area of a window. Without this step, you'll get a window

View File

@ -33,7 +33,6 @@
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
# include <FramelessHelper/Core/private/winverhelper_p.h> # include <FramelessHelper/Core/private/winverhelper_p.h>
#endif // Q_OS_WINDOWS #endif // Q_OS_WINDOWS
#include <QtCore/qmutex.h>
#include <QtCore/qtimer.h> #include <QtCore/qtimer.h>
#include <QtCore/qeventloop.h> #include <QtCore/qeventloop.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
@ -86,7 +85,6 @@ struct QuickHelperData
struct QuickHelper struct QuickHelper
{ {
QMutex mutex;
QHash<WId, QuickHelperData> data = {}; QHash<WId, QuickHelperData> data = {};
}; };
@ -160,7 +158,6 @@ void FramelessQuickHelperPrivate::setTitleBarItem(QQuickItem *value)
if (!value) { if (!value) {
return; return;
} }
const QMutexLocker locker(&g_quickHelper()->mutex);
QuickHelperData *data = getWindowDataMutable(); QuickHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -181,13 +178,10 @@ void FramelessQuickHelperPrivate::attach()
return; return;
} }
g_quickHelper()->mutex.lock();
QuickHelperData * const data = getWindowDataMutable(); QuickHelperData * const data = getWindowDataMutable();
if (!data || data->ready) { if (!data || data->ready) {
g_quickHelper()->mutex.unlock();
return; return;
} }
g_quickHelper()->mutex.unlock();
SystemParameters params = {}; SystemParameters params = {};
params.getWindowId = [window]() -> WId { return window->winId(); }; params.getWindowId = [window]() -> WId { return window->winId(); };
@ -228,10 +222,8 @@ void FramelessQuickHelperPrivate::attach()
FramelessManager::instance()->addWindow(&params); FramelessManager::instance()->addWindow(&params);
g_quickHelper()->mutex.lock();
data->params = params; data->params = params;
data->ready = true; data->ready = true;
g_quickHelper()->mutex.unlock();
// We have to wait for a little time before moving the top level window // We have to wait for a little time before moving the top level window
// , because the platform window may not finish initializing by the time // , because the platform window may not finish initializing by the time
@ -258,7 +250,6 @@ void FramelessQuickHelperPrivate::detach()
return; return;
} }
const WId windowId = w->winId(); const WId windowId = w->winId();
const QMutexLocker locker(&g_quickHelper()->mutex);
if (!g_quickHelper()->data.contains(windowId)) { if (!g_quickHelper()->data.contains(windowId)) {
return; return;
} }
@ -273,7 +264,6 @@ void FramelessQuickHelperPrivate::setSystemButton(QQuickItem *item, const QuickG
if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) { if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) {
return; return;
} }
const QMutexLocker locker(&g_quickHelper()->mutex);
QuickHelperData *data = getWindowDataMutable(); QuickHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -306,7 +296,6 @@ void FramelessQuickHelperPrivate::setHitTestVisible(QQuickItem *item, const bool
if (!item) { if (!item) {
return; return;
} }
const QMutexLocker locker(&g_quickHelper()->mutex);
QuickHelperData *data = getWindowDataMutable(); QuickHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -326,7 +315,6 @@ void FramelessQuickHelperPrivate::setHitTestVisible(const QRect &rect, const boo
if (!rect.isValid()) { if (!rect.isValid()) {
return; return;
} }
const QMutexLocker locker(&g_quickHelper()->mutex);
QuickHelperData *data = getWindowDataMutable(); QuickHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -941,7 +929,6 @@ QuickHelperData FramelessQuickHelperPrivate::getWindowData() const
return {}; return {};
} }
const WId windowId = window->winId(); const WId windowId = window->winId();
const QMutexLocker locker(&g_quickHelper()->mutex);
if (!g_quickHelper()->data.contains(windowId)) { if (!g_quickHelper()->data.contains(windowId)) {
g_quickHelper()->data.insert(windowId, {}); g_quickHelper()->data.insert(windowId, {});
} }

View File

@ -27,7 +27,6 @@
#include <FramelessHelper/Core/micamaterial.h> #include <FramelessHelper/Core/micamaterial.h>
#include <FramelessHelper/Core/framelessmanager.h> #include <FramelessHelper/Core/framelessmanager.h>
#include <FramelessHelper/Core/private/micamaterial_p.h> #include <FramelessHelper/Core/private/micamaterial_p.h>
#include <QtCore/qmutex.h>
#include <QtCore/qloggingcategory.h> #include <QtCore/qloggingcategory.h>
#include <QtGui/qscreen.h> #include <QtGui/qscreen.h>
#include <QtGui/qpainter.h> #include <QtGui/qpainter.h>
@ -58,13 +57,6 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
using namespace Global; using namespace Global;
struct QuickMicaData
{
QMutex mutex;
};
Q_GLOBAL_STATIC(QuickMicaData, g_data)
class WallpaperImageNode : public QObject, public QSGTransformNode class WallpaperImageNode : public QObject, public QSGTransformNode
{ {
Q_OBJECT Q_OBJECT
@ -102,15 +94,11 @@ WallpaperImageNode::~WallpaperImageNode() = default;
void WallpaperImageNode::initialize() void WallpaperImageNode::initialize()
{ {
g_data()->mutex.lock();
QQuickWindow * const window = m_item->window(); QQuickWindow * const window = m_item->window();
m_node = new QSGSimpleTextureNode; m_node = new QSGSimpleTextureNode;
m_node->setFiltering(QSGTexture::Linear); m_node->setFiltering(QSGTexture::Linear);
g_data()->mutex.unlock();
maybeGenerateWallpaperImageCache(); maybeGenerateWallpaperImageCache();
maybeUpdateWallpaperImageClipRect(); maybeUpdateWallpaperImageClipRect();
@ -124,7 +112,6 @@ void WallpaperImageNode::initialize()
void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force) void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force)
{ {
const QMutexLocker locker(&g_data()->mutex);
if (!m_pixmapCache.isNull() && !force) { if (!m_pixmapCache.isNull() && !force) {
return; return;
} }
@ -147,7 +134,6 @@ void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force)
void WallpaperImageNode::maybeUpdateWallpaperImageClipRect() void WallpaperImageNode::maybeUpdateWallpaperImageClipRect()
{ {
const QMutexLocker locker(&g_data()->mutex);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
const QSizeF itemSize = m_item->size(); const QSizeF itemSize = m_item->size();
#else #else

View File

@ -35,7 +35,6 @@
#include <FramelessHelper/Core/utils.h> #include <FramelessHelper/Core/utils.h>
#include <FramelessHelper/Core/private/framelessconfig_p.h> #include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <FramelessHelper/Core/private/framelesshelpercore_global_p.h> #include <FramelessHelper/Core/private/framelesshelpercore_global_p.h>
#include <QtCore/qmutex.h>
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qtimer.h> #include <QtCore/qtimer.h>
#include <QtCore/qeventloop.h> #include <QtCore/qeventloop.h>
@ -82,7 +81,6 @@ struct WidgetsHelperData
struct WidgetsHelper struct WidgetsHelper
{ {
QMutex mutex;
QHash<WId, WidgetsHelperData> data = {}; QHash<WId, WidgetsHelperData> data = {};
}; };
@ -440,7 +438,6 @@ void FramelessWidgetsHelperPrivate::setTitleBarWidget(QWidget *widget)
if (!widget) { if (!widget) {
return; return;
} }
const QMutexLocker locker(&g_widgetsHelper()->mutex);
WidgetsHelperData *data = getWindowDataMutable(); WidgetsHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -463,7 +460,6 @@ void FramelessWidgetsHelperPrivate::setHitTestVisible(QWidget *widget, const boo
if (!widget) { if (!widget) {
return; return;
} }
const QMutexLocker locker(&g_widgetsHelper()->mutex);
WidgetsHelperData *data = getWindowDataMutable(); WidgetsHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -483,7 +479,6 @@ void FramelessWidgetsHelperPrivate::setHitTestVisible(const QRect &rect, const b
if (!rect.isValid()) { if (!rect.isValid()) {
return; return;
} }
const QMutexLocker locker(&g_widgetsHelper()->mutex);
WidgetsHelperData *data = getWindowDataMutable(); WidgetsHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;
@ -530,13 +525,10 @@ void FramelessWidgetsHelperPrivate::attach()
window->setAttribute(Qt::WA_NativeWindow); window->setAttribute(Qt::WA_NativeWindow);
} }
g_widgetsHelper()->mutex.lock();
WidgetsHelperData * const data = getWindowDataMutable(); WidgetsHelperData * const data = getWindowDataMutable();
if (!data || data->ready) { if (!data || data->ready) {
g_widgetsHelper()->mutex.unlock();
return; return;
} }
g_widgetsHelper()->mutex.unlock();
SystemParameters params = {}; SystemParameters params = {};
params.getWindowId = [window]() -> WId { return window->winId(); }; params.getWindowId = [window]() -> WId { return window->winId(); };
@ -575,10 +567,8 @@ void FramelessWidgetsHelperPrivate::attach()
FramelessManager::instance()->addWindow(&params); FramelessManager::instance()->addWindow(&params);
g_widgetsHelper()->mutex.lock();
data->params = params; data->params = params;
data->ready = true; data->ready = true;
g_widgetsHelper()->mutex.unlock();
// We have to wait for a little time before moving the top level window // We have to wait for a little time before moving the top level window
// , because the platform window may not finish initializing by the time // , because the platform window may not finish initializing by the time
@ -604,7 +594,6 @@ void FramelessWidgetsHelperPrivate::detach()
return; return;
} }
const WId windowId = m_window->winId(); const WId windowId = m_window->winId();
const QMutexLocker locker(&g_widgetsHelper()->mutex);
if (!g_widgetsHelper()->data.contains(windowId)) { if (!g_widgetsHelper()->data.contains(windowId)) {
return; return;
} }
@ -649,7 +638,6 @@ WidgetsHelperData FramelessWidgetsHelperPrivate::getWindowData() const
return {}; return {};
} }
const WId windowId = m_window->winId(); const WId windowId = m_window->winId();
const QMutexLocker locker(&g_widgetsHelper()->mutex);
if (!g_widgetsHelper()->data.contains(windowId)) { if (!g_widgetsHelper()->data.contains(windowId)) {
g_widgetsHelper()->data.insert(windowId, {}); g_widgetsHelper()->data.insert(windowId, {});
} }
@ -942,7 +930,6 @@ void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const Syste
if (!widget || (buttonType == SystemButtonType::Unknown)) { if (!widget || (buttonType == SystemButtonType::Unknown)) {
return; return;
} }
const QMutexLocker locker(&g_widgetsHelper()->mutex);
WidgetsHelperData *data = getWindowDataMutable(); WidgetsHelperData *data = getWindowDataMutable();
if (!data) { if (!data) {
return; return;