Fix a crash when opening pro file (Qt6 build)

When move c'tor of ProFunctionDef was introduced
it became possible, that m_pro may be NULL.
In this case we need to destruct this invalid state
of ProFunctionDef in a special way: we ensure,
that m_pro is not null before calling deref().

Amends: bf5cc934ea

Cherry-picks: 907923b7cafad8cff6f0f5c8764e9181ac1531bd from qtbase
Task-number: QTCREATORBUG-24840
Change-Id: I5b2643f2241407101dbf95a8d6ea9974cf8ae6ea
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2020-11-23 23:03:48 +01:00
parent 038cac9fe6
commit a3926b282e

View File

@@ -421,10 +421,11 @@ public:
ProFunctionDef(const ProFunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); } ProFunctionDef(const ProFunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); }
ProFunctionDef(ProFunctionDef &&other) Q_DECL_NOTHROW ProFunctionDef(ProFunctionDef &&other) Q_DECL_NOTHROW
: m_pro(other.m_pro), m_offset(other.m_offset) { other.m_pro = nullptr; } : m_pro(other.m_pro), m_offset(other.m_offset) { other.m_pro = nullptr; }
~ProFunctionDef() { m_pro->deref(); } ~ProFunctionDef() { if (m_pro) m_pro->deref(); }
ProFunctionDef &operator=(const ProFunctionDef &o) ProFunctionDef &operator=(const ProFunctionDef &o)
{ {
if (this != &o) { if (this != &o) {
if (m_pro)
m_pro->deref(); m_pro->deref();
m_pro = o.m_pro; m_pro = o.m_pro;
m_pro->ref(); m_pro->ref();