Detect that we are looking for an empty element and quit early

Otherwise we just go through all the fallbacks unnecessarily
This commit is contained in:
Aleix Pol 2020-09-28 00:53:44 +02:00 committed by Aleix Pol Gonzalez
parent fe7598c6ef
commit 93de15f545
2 changed files with 2 additions and 2 deletions

View File

@ -108,7 +108,7 @@ void FrameSvg::setElementPrefix(Plasma::Types::Location location)
void FrameSvg::setElementPrefix(const QString &prefix)
{
if (!hasElement(prefix % QLatin1String("-center"))) {
if (prefix.isEmpty() || !hasElement(prefix % QLatin1String("-center"))) {
d->prefix.clear();
} else {
d->prefix = prefix;

View File

@ -868,7 +868,7 @@ QRectF Svg::elementRect(const QString &elementId) const
bool Svg::hasElement(const QString &elementId) const
{
if (d->path.isNull() && d->themePath.isNull()) {
if (elementId.isEmpty() || (d->path.isNull() && d->themePath.isNull())) {
return false;
}