Fix loading xcursor themes with invalid Inherits field
Xcursor loading can get stuck in an infinite recursion if index.theme file indicates that the theme inherits itself. In order to prevent that, keep track of the loaded so far themes and avoid loading already loaded themes. BUG: 457926
This commit is contained in:
parent
245eb822c7
commit
2d2f972bff
1 changed files with 28 additions and 12 deletions
|
@ -12,7 +12,9 @@
|
|||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QSet>
|
||||
#include <QSharedData>
|
||||
#include <QStack>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace KWin
|
||||
|
@ -157,6 +159,18 @@ static QStringList searchPaths()
|
|||
void KXcursorThemePrivate::load(const QString &themeName, int size, qreal devicePixelRatio)
|
||||
{
|
||||
const QStringList paths = searchPaths();
|
||||
|
||||
QStack<QString> stack;
|
||||
QSet<QString> loaded;
|
||||
|
||||
stack.push(themeName);
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
const QString themeName = stack.pop();
|
||||
if (loaded.contains(themeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList inherits;
|
||||
|
||||
for (const QString &path : paths) {
|
||||
|
@ -171,8 +185,10 @@ void KXcursorThemePrivate::load(const QString &themeName, int size, qreal device
|
|||
}
|
||||
}
|
||||
|
||||
for (const QString &inherit : inherits) {
|
||||
load(inherit, size, devicePixelRatio);
|
||||
loaded.insert(themeName);
|
||||
for (auto it = inherits.crbegin(); it != inherits.crend(); ++it) {
|
||||
stack.push(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue