mirror of
https://github.com/SFML/SFML.git
synced 2025-01-18 23:35:11 +08:00
Do not cache atom name if XInternAtom fails
If `XInternAtom` is called with `onlyIfExists` set, then it can legitimately return `None`. We should not cache this value because it might change in the future. This bug can sometimes be triggered because we use `getAtom("UTF8_STRING", true)` and `getAtom("UTF8_STRING")`. If the first call caches `None` because the atom didn't exist, then the second call could return `None` instead of creating a new atom like it should.
This commit is contained in:
parent
f88b768ba6
commit
ad70442246
@ -129,7 +129,8 @@ Atom getAtom(const std::string& name, bool onlyIfExists)
|
|||||||
|
|
||||||
const auto display = openDisplay();
|
const auto display = openDisplay();
|
||||||
const Atom atom = XInternAtom(display.get(), name.c_str(), onlyIfExists ? True : False);
|
const Atom atom = XInternAtom(display.get(), name.c_str(), onlyIfExists ? True : False);
|
||||||
atoms[name] = atom;
|
if (atom)
|
||||||
|
atoms[name] = atom;
|
||||||
|
|
||||||
return atom;
|
return atom;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user