avoid potential deadlocks
And some other minor tweaks. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
c914992aa4
commit
f97f000cc7
|
@ -97,6 +97,7 @@ private:
|
|||
QColor m_savedWindowBackgroundColor = {};
|
||||
bool m_blurBehindWindowEnabled = false;
|
||||
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
|
||||
bool m_destroying = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -92,6 +92,7 @@ private:
|
|||
QColor m_savedWindowBackgroundColor = {};
|
||||
bool m_blurBehindWindowEnabled = false;
|
||||
QPointer<QWidget> m_window = nullptr;
|
||||
bool m_destroying = false;
|
||||
};
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "framelessmanager_p.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <QtGui/qfontdatabase.h>
|
||||
|
@ -73,14 +74,15 @@ Q_GLOBAL_STATIC(FramelessManagerHelper, g_helper)
|
|||
|
||||
Q_GLOBAL_STATIC(FramelessManager, g_manager)
|
||||
|
||||
[[maybe_unused]] static constexpr const char kGlobalFlagVarName[] = "__FRAMELESSHELPER__";
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFilePath, ":/org.wangwenx190.FramelessHelper/resources/fonts/Micon.ttf")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_win11, "Segoe Fluent Icons")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_win10, "Segoe MDL2 Assets")
|
||||
FRAMELESSHELPER_STRING_CONSTANT2(IconFontFamilyName_common, "micon_nb")
|
||||
#ifdef Q_OS_MACOS
|
||||
static constexpr const int kIconFontPointSize = 10;
|
||||
[[maybe_unused]] static constexpr const int kIconFontPointSize = 10;
|
||||
#else
|
||||
static constexpr const int kIconFontPointSize = 8;
|
||||
[[maybe_unused]] static constexpr const int kIconFontPointSize = 8;
|
||||
#endif
|
||||
|
||||
[[nodiscard]] static inline QString iconFontFamilyName()
|
||||
|
@ -352,11 +354,21 @@ void FramelessManagerPrivate::initialize()
|
|||
m_wallpaperAspectStyle = Utils::getWallpaperAspectStyle();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
QStyleHints * const styleHints = QGuiApplication::styleHints();
|
||||
Q_ASSERT(styleHints);
|
||||
if (styleHints) {
|
||||
connect(styleHints, &QStyleHints::appearanceChanged, this, [this](const Qt::Appearance appearance){
|
||||
Q_UNUSED(appearance);
|
||||
notifySystemThemeHasChangedOrNot();
|
||||
});
|
||||
}
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
static bool flagSet = false;
|
||||
if (!flagSet) {
|
||||
flagSet = true;
|
||||
// Set a global flag so that people can check whether FramelessHelper is being
|
||||
// used without actually accessing the FramelessHelper interface.
|
||||
qApp->setProperty(kGlobalFlagVarName, FramelessHelper::Core::version().version);
|
||||
}
|
||||
}
|
||||
|
||||
FramelessManager::FramelessManager(QObject *parent) :
|
||||
|
|
|
@ -282,7 +282,9 @@ struct SYSTEM_METRIC
|
|||
if (code == ERROR_SUCCESS) {
|
||||
return kSuccessMessageText;
|
||||
}
|
||||
#if 0 // The following code works well, we commented it out just because we want to use as many Qt functionalities as possible.
|
||||
static constexpr const bool flag = false;
|
||||
if (flag) {
|
||||
// The following code works well, we commented it out just because we want to use as many Qt functionalities as possible.
|
||||
LPWSTR buf = nullptr;
|
||||
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>(&buf), 0, nullptr) == 0) {
|
||||
|
@ -291,9 +293,9 @@ struct SYSTEM_METRIC
|
|||
const QString errorText = QString::fromWCharArray(buf).trimmed();
|
||||
LocalFree(buf);
|
||||
buf = nullptr;
|
||||
#else
|
||||
return kErrorMessageTemplate.arg(function, QString::number(code), errorText);
|
||||
}
|
||||
const QString errorText = QSystemError::windowsString(code);
|
||||
#endif
|
||||
return kErrorMessageTemplate.arg(function, QString::number(code), errorText);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q
|
|||
|
||||
FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate()
|
||||
{
|
||||
m_destroying = true;
|
||||
extendsContentIntoTitleBar(false);
|
||||
m_extendIntoTitleBar = std::nullopt;
|
||||
}
|
||||
|
@ -141,7 +142,9 @@ void FramelessQuickHelperPrivate::extendsContentIntoTitleBar(const bool value)
|
|||
detach();
|
||||
}
|
||||
m_extendIntoTitleBar = value;
|
||||
if (!m_destroying) {
|
||||
emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("extendsContentIntoTitleBarChanged"));
|
||||
}
|
||||
}
|
||||
|
||||
QQuickItem *FramelessQuickHelperPrivate::getTitleBarItem() const
|
||||
|
|
|
@ -109,6 +109,7 @@ FramelessWidgetsHelperPrivate::FramelessWidgetsHelperPrivate(FramelessWidgetsHel
|
|||
|
||||
FramelessWidgetsHelperPrivate::~FramelessWidgetsHelperPrivate()
|
||||
{
|
||||
m_destroying = true;
|
||||
extendsContentIntoTitleBar(false);
|
||||
}
|
||||
|
||||
|
@ -448,7 +449,9 @@ void FramelessWidgetsHelperPrivate::extendsContentIntoTitleBar(const bool value)
|
|||
} else {
|
||||
detach();
|
||||
}
|
||||
if (!m_destroying) {
|
||||
emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("extendsContentIntoTitleBarChanged"));
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *FramelessWidgetsHelperPrivate::findTopLevelWindow() const
|
||||
|
|
Loading…
Reference in New Issue