Skip to content

Commit

Permalink
fix: crashed on palette destroyed
Browse files Browse the repository at this point in the history
do not set value if app is about to quit
Issue: linuxdeepin/dtk#193
  • Loading branch information
kegechen committed Aug 27, 2024
1 parent c79435a commit ac94025
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/private/dqmlglobalobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ DColor DColor::opacity(qint8 floatValue) const
return newColor;
}

bool DQMLGlobalObjectPrivate::g_appAboutToQuit = false;
DQMLGlobalObjectPrivate::DQMLGlobalObjectPrivate(DQMLGlobalObject *qq)
: DTK_CORE_NAMESPACE::DObjectPrivate(qq)
{
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [](){
g_appAboutToQuit = true;
});
}

void DQMLGlobalObjectPrivate::ensurePalette()
Expand Down
1 change: 1 addition & 0 deletions src/private/dqmlglobalobject_p_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DQMLGlobalObjectPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
QString deepinWebsiteName;
QString deepinWebsiteLink;
QString deepinDistributionOrgLogo;
static bool g_appAboutToQuit;

private:
D_DECLARE_PUBLIC(DQMLGlobalObject)
Expand Down
3 changes: 2 additions & 1 deletion src/private/dquickcontrolpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "dquickcontrolpalette_p.h"
#include "dquickglobal_p.h"
#include "dqmlglobalobject_p_p.h"

#include <DGuiApplicationHelper>

Expand Down Expand Up @@ -937,7 +938,7 @@ void DQuickControlColorSelector::notifyColorPropertyChanged()

void DQuickControlColorSelector::updatePropertyFromName(const QByteArray &name, const DQuickControlPalette *palette)
{
if (QCoreApplication::closingDown())
if (QCoreApplication::closingDown() || DQMLGlobalObjectPrivate::g_appAboutToQuit)
return;
Q_ASSERT(!name.isEmpty());
QColor color;
Expand Down

0 comments on commit ac94025

Please sign in to comment.