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

mcallegari / qlcplus / 27362797676

11 Jun 2026 04:45PM UTC coverage: 35.268% (-0.02%) from 35.286%
27362797676

push

github

mcallegari
qmlui: use UIDs and reset feedback on input patch removal (fix #2042)

18433 of 52265 relevant lines covered (35.27%)

41116.73 hits per line

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

80.85
/engine/src/outputpatch.cpp
1
/*
2
  Q Light Controller
3
  outputpatch.cpp
4

5
  Copyright (c) Heikki Junnila
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
#if defined(WIN32) || defined(Q_OS_WIN)
21
#   define WIN32_LEAN_AND_MEAN
22
#   include <Windows.h>
23
#else
24
#   include <unistd.h>
25
#endif
26

27
#include "qlcioplugin.h"
28
#include "outputpatch.h"
29

30
#define GRACE_MS 1
31

32
/*****************************************************************************
33
 * Initialization
34
 *****************************************************************************/
35

36
OutputPatch::OutputPatch(QObject* parent)
1✔
37
    : QObject(parent)
38
    , m_plugin(NULL)
1✔
39
    , m_pluginLine(QLCIOPlugin::invalidLine())
2✔
40
    , m_universe(UINT_MAX)
1✔
41
    , m_paused(false)
1✔
42
    , m_blackout(false)
1✔
43
{
44
}
1✔
45

46
OutputPatch::OutputPatch(quint32 universe, QObject* parent)
168✔
47
    : QObject(parent)
48
    , m_plugin(NULL)
168✔
49
    , m_pluginLine(QLCIOPlugin::invalidLine())
336✔
50
    , m_universe(universe)
168✔
51
    , m_paused(false)
168✔
52
    , m_blackout(false)
168✔
53
{
54
}
168✔
55

56
OutputPatch::~OutputPatch()
337✔
57
{
58
    if (m_plugin != NULL)
169✔
59
        m_plugin->closeOutput(m_pluginLine, m_universe);
168✔
60
}
337✔
61

62
/****************************************************************************
63
 * Plugin & Output
64
 ****************************************************************************/
65

66
bool OutputPatch::set(QLCIOPlugin* plugin, quint32 output)
169✔
67
{
68
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
169✔
69
        m_plugin->closeOutput(m_pluginLine, m_universe);
1✔
70

71
    m_plugin = plugin;
169✔
72
    m_pluginLine = output;
169✔
73

74
    if (m_plugin != NULL)
169✔
75
    {
76
        emit pluginNameChanged();
169✔
77
        if (m_pluginLine != QLCIOPlugin::invalidLine())
169✔
78
            emit outputNameChanged();
169✔
79
    }
80

81
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
169✔
82
        return m_plugin->openOutput(m_pluginLine, m_universe);
169✔
83

84
    return false;
×
85
}
86

87
bool OutputPatch::reconnect()
1✔
88
{
89
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
1✔
90
    {
91
        m_plugin->closeOutput(m_pluginLine, m_universe);
1✔
92
#if defined(WIN32) || defined(Q_OS_WIN)
93
        Sleep(GRACE_MS);
94
#else
95
        usleep(GRACE_MS * 1000);
1✔
96
#endif
97
        bool ret = m_plugin->openOutput(m_pluginLine, m_universe);
1✔
98
        if (ret == true)
1✔
99
        {
100
            QMap<QString, QVariant>::iterator it = m_parametersCache.begin();
1✔
101
            for (; it != m_parametersCache.end(); it++)
1✔
102
                m_plugin->setParameter(m_universe, m_pluginLine, QLCIOPlugin::Output, it.key(), it.value());
×
103
        }
104
        return ret;
1✔
105
    }
106
    return false;
×
107
}
108

109
QString OutputPatch::pluginName() const
12✔
110
{
111
    if (m_plugin != NULL)
12✔
112
        return m_plugin->name();
11✔
113
    else
114
        return KOutputNone;
1✔
115
}
116

117
QLCIOPlugin* OutputPatch::plugin() const
7✔
118
{
119
    return m_plugin;
7✔
120
}
121

122
QString OutputPatch::outputName() const
4✔
123
{
124
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine() &&
7✔
125
        m_pluginLine < quint32(m_plugin->outputs().size()))
7✔
126
    {
127
        return m_plugin->outputs()[m_pluginLine];
3✔
128
    }
129
    else
130
    {
131
        return KOutputNone;
1✔
132
    }
133
}
134

135
QString OutputPatch::outputUID() const
×
136
{
137
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine() &&
×
138
        m_pluginLine < quint32(m_plugin->outputs().size()))
×
139
    {
140
        return m_plugin->outputsUID()[m_pluginLine];
×
141
    }
142
    else
143
    {
144
        return KOutputNone;
×
145
    }
146
}
147

148
quint32 OutputPatch::output() const
11✔
149
{
150
    return m_pluginLine;
11✔
151
}
152

153
bool OutputPatch::isPatched() const
×
154
{
155
    return output() != QLCIOPlugin::invalidLine() && m_plugin != NULL;
×
156
}
157

158
void OutputPatch::setPluginParameter(QString prop, QVariant value)
454✔
159
{
160
    m_parametersCache[prop] = value;
454✔
161
    if (m_plugin != NULL)
454✔
162
        m_plugin->setParameter(m_universe, m_pluginLine, QLCIOPlugin::Output, prop, value);
454✔
163
}
454✔
164

165
QMap<QString, QVariant> OutputPatch::getPluginParameters()
×
166
{
167
    if (m_plugin != NULL)
×
168
        return m_plugin->getParameters(m_universe, m_pluginLine, QLCIOPlugin::Output);
×
169

170
    return QMap<QString, QVariant>();
×
171
}
172

173
/*****************************************************************************
174
 * Value dump
175
 *****************************************************************************/
176
bool OutputPatch::paused() const
×
177
{
178
    return m_paused;
×
179
}
180

181
void OutputPatch::setPaused(bool paused)
2✔
182
{
183
    if (m_paused == paused)
2✔
184
        return;
×
185

186
    m_paused = paused;
2✔
187

188
    if (m_pauseBuffer.length())
2✔
189
        m_pauseBuffer.clear();
1✔
190

191
    emit pausedChanged(m_paused);
2✔
192
}
193

194
bool OutputPatch::blackout() const
24,790✔
195
{
196
    return m_blackout;
24,790✔
197
}
198

199
void OutputPatch::setBlackout(bool blackout)
12✔
200
{
201
    if (m_blackout == blackout)
12✔
202
        return;
×
203

204
    m_blackout = blackout;
12✔
205
    emit blackoutChanged(m_blackout);
12✔
206
}
207

208
void OutputPatch::dump(quint32 universe, const QByteArray& data, bool dataChanged)
24,794✔
209
{
210
    /* Don't do anything if there is no plugin and/or output line. */
211
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
24,794✔
212
    {
213
        if (m_paused)
24,794✔
214
        {
215
            if (m_pauseBuffer.isNull())
2✔
216
                m_pauseBuffer.append(data);
1✔
217

218
            m_plugin->writeUniverse(universe, m_pluginLine, m_pauseBuffer, dataChanged);
2✔
219
        }
220
        else
221
        {
222
            m_plugin->writeUniverse(universe, m_pluginLine, data, dataChanged);
24,792✔
223
        }
224
    }
225
}
24,794✔
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