forked from qt-creator/qt-creator
GLSL: Fix crash when built with Qt 6
In Qt 6 references (and pointers) to elements in a container are invalidated when the container size changes. Simply move to std::unordered_set which guarantees references to stay valid. Fixes: QTCREATORBUG-25641 Task-number: QTCREATORBUG-24098 Change-Id: I9f1110419bd2940c182b4a24629d9ab718ca2af6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -87,30 +87,30 @@ Engine::~Engine()
|
|||||||
|
|
||||||
const QString *Engine::identifier(const QString &s)
|
const QString *Engine::identifier(const QString &s)
|
||||||
{
|
{
|
||||||
return &(*_identifiers.insert(s));
|
return &(*_identifiers.insert(s).first);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString *Engine::identifier(const char *s, int n)
|
const QString *Engine::identifier(const char *s, int n)
|
||||||
{
|
{
|
||||||
return &(*_identifiers.insert(QString::fromLatin1(s, n)));
|
return &(*_identifiers.insert(QString::fromLatin1(s, n)).first);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> Engine::identifiers() const
|
std::unordered_set<QString> Engine::identifiers() const
|
||||||
{
|
{
|
||||||
return _identifiers;
|
return _identifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString *Engine::number(const QString &s)
|
const QString *Engine::number(const QString &s)
|
||||||
{
|
{
|
||||||
return &(*_numbers.insert(s));
|
return &(*_numbers.insert(s).first);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString *Engine::number(const char *s, int n)
|
const QString *Engine::number(const char *s, int n)
|
||||||
{
|
{
|
||||||
return &(*_numbers.insert(QString::fromLatin1(s, n)));
|
return &(*_numbers.insert(QString::fromLatin1(s, n)).first);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> Engine::numbers() const
|
std::unordered_set<QString> Engine::numbers() const
|
||||||
{
|
{
|
||||||
return _numbers;
|
return _numbers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,10 @@
|
|||||||
#include "glslmemorypool.h"
|
#include "glslmemorypool.h"
|
||||||
#include "glsltypes.h"
|
#include "glsltypes.h"
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
#include <qset.h>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace GLSL {
|
namespace GLSL {
|
||||||
|
|
||||||
@@ -91,11 +92,11 @@ public:
|
|||||||
|
|
||||||
const QString *identifier(const QString &s);
|
const QString *identifier(const QString &s);
|
||||||
const QString *identifier(const char *s, int n);
|
const QString *identifier(const char *s, int n);
|
||||||
QSet<QString> identifiers() const;
|
std::unordered_set<QString> identifiers() const;
|
||||||
|
|
||||||
const QString *number(const QString &s);
|
const QString *number(const QString &s);
|
||||||
const QString *number(const char *s, int n);
|
const QString *number(const char *s, int n);
|
||||||
QSet<QString> numbers() const;
|
std::unordered_set<QString> numbers() const;
|
||||||
|
|
||||||
// types
|
// types
|
||||||
const UndefinedType *undefinedType();
|
const UndefinedType *undefinedType();
|
||||||
@@ -128,8 +129,8 @@ public:
|
|||||||
void error(int line, const QString &message);
|
void error(int line, const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSet<QString> _identifiers;
|
std::unordered_set<QString> _identifiers;
|
||||||
QSet<QString> _numbers;
|
std::unordered_set<QString> _numbers;
|
||||||
TypeTable<VectorType> _vectorTypes;
|
TypeTable<VectorType> _vectorTypes;
|
||||||
TypeTable<MatrixType> _matrixTypes;
|
TypeTable<MatrixType> _matrixTypes;
|
||||||
TypeTable<ArrayType> _arrayTypes;
|
TypeTable<ArrayType> _arrayTypes;
|
||||||
|
|||||||
Reference in New Issue
Block a user