• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 14433244236

13 Apr 2025 08:53PM UTC coverage: 31.914% (+0.007%) from 31.907%
14433244236

Pull #1717

github

web-flow
Merge 47e848b1a into c523d61b1
Pull Request #1717: engine: fix 3 memory leaks

8 of 9 new or added lines in 4 files covered. (88.89%)

111 existing lines in 2 files now uncovered.

14721 of 46127 relevant lines covered (31.91%)

26421.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.89
/engine/src/qlcmodifierscache.cpp
1
/*
2
  Q Light Controller Plus
3
  qlcmodifierscache.cpp
4

5
  Copyright (c) Massimo Callegari
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QDebug>
21

22
#include "qlcmodifierscache.h"
23
#include "channelmodifier.h"
24
#include "qlcconfig.h"
25
#include "qlcfile.h"
26

27
QLCModifiersCache::QLCModifiersCache()
177✔
28
{
29
}
177✔
30

31
QLCModifiersCache::~QLCModifiersCache()
177✔
32
{
33
    qDeleteAll(m_modifiers);
177✔
34
}
177✔
35

UNCOV
36
bool QLCModifiersCache::addModifier(ChannelModifier *modifier)
×
37
{
38
    if (m_modifiers.contains(modifier->name()))
×
39
        return false;
40

41
    //qDebug() << "[QLCModifiersCache] added modifier" << modifier->name();
42
    m_modifiers[modifier->name()] = modifier;
×
43
    return true;
×
44
}
45

46
QList<QString> QLCModifiersCache::templateNames()
×
47
{
48
    return m_modifiers.keys();
×
49
}
50

51
ChannelModifier *QLCModifiersCache::modifier(QString name)
×
52
{
NEW
53
    return m_modifiers.value(name, NULL);
×
54
}
55

56
QDir QLCModifiersCache::systemTemplateDirectory()
×
57
{
58
    return QLCFile::systemDirectory(QString(MODIFIERSTEMPLATEDIR), QString(KExtModifierTemplate));
×
59
}
60

61
QDir QLCModifiersCache::userTemplateDirectory()
×
62
{
63
    return QLCFile::userDirectory(QString(USERMODIFIERSTEMPLATEDIR), QString(MODIFIERSTEMPLATEDIR),
×
64
                                  QStringList() << QString("*%1").arg(KExtModifierTemplate));
×
65
}
66

67
bool QLCModifiersCache::load(const QDir& dir, bool systemTemplates)
×
68
{
69
    qDebug() << Q_FUNC_INFO << dir.path();
70

71
    if (dir.exists() == false || dir.isReadable() == false)
×
72
        return false;
×
73

74
    ChannelModifier::Type type;
75
    if (systemTemplates ==true)
×
76
        type = ChannelModifier::SystemTemplate;
77
    else
78
        type = ChannelModifier::UserTemplate;
79

80
    /* Attempt to read all specified files from the given directory */
81
    QStringListIterator it(dir.entryList());
×
82
    while (it.hasNext() == true)
×
83
    {
84
        QString path(dir.absoluteFilePath(it.next()));
×
85

86
        if (path.toLower().endsWith(KExtModifierTemplate) == true)
×
87
        {
88
            ChannelModifier* chMod = new ChannelModifier();
×
89
            Q_ASSERT(chMod != NULL);
90

91
            QFile::FileError error = chMod->loadXML(path, type);
×
92
            if (error == QFile::NoError)
×
93
            {
94
                /* Delete the modifier if it's a duplicate. */
95
                if (addModifier(chMod) == false)
×
96
                {
97
                    delete chMod;
×
98
                    chMod = NULL;
99
                }
100
            }
101
            else
102
            {
103
                qWarning() << Q_FUNC_INFO << "Channel modifier template loading from"
×
104
                           << path << "failed:" << QLCFile::errorString(error);
×
105
                delete chMod;
×
106
                chMod = NULL;
107
            }
108
        }
109
        else
110
            qWarning() << Q_FUNC_INFO << "Unrecognized template extension:" << path;
×
111
    }
×
112

113
    return true;
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc