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

mcallegari / qlcplus / 25128119917

29 Apr 2026 07:00PM UTC coverage: 34.05% (+0.002%) from 34.048%
25128119917

Pull #1998

github

web-flow
Merge ce41d30f6 into b7c5f4799
Pull Request #1998: Fixed plugin parameters not saved when device is disconnected

4 of 10 new or added lines in 2 files covered. (40.0%)

17762 of 52165 relevant lines covered (34.05%)

41159.18 hits per line

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

82.61
/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
quint32 OutputPatch::output() const
11✔
136
{
137
    return m_pluginLine;
11✔
138
}
139

140
bool OutputPatch::isPatched() const
×
141
{
142
    return output() != QLCIOPlugin::invalidLine() && m_plugin != NULL;
×
143
}
144

145
void OutputPatch::setPluginParameter(QString prop, QVariant value)
454✔
146
{
147
    m_parametersCache[prop] = value;
454✔
148
    if (m_plugin != NULL)
454✔
149
        m_plugin->setParameter(m_universe, m_pluginLine, QLCIOPlugin::Output, prop, value);
454✔
150
}
454✔
151

152
QMap<QString, QVariant> OutputPatch::getPluginParameters()
×
153
{
154
    if (m_plugin != NULL)
×
155
    {
NEW
156
        const auto params = m_plugin->getParameters(m_universe, m_pluginLine, QLCIOPlugin::Output);
×
NEW
157
        if (!params.isEmpty())
×
NEW
158
            return params;
×
NEW
159
    }
×
NEW
160
    return m_parametersCache;
×
161
}
162

163
/*****************************************************************************
164
 * Value dump
165
 *****************************************************************************/
166
bool OutputPatch::paused() const
×
167
{
168
    return m_paused;
×
169
}
170

171
void OutputPatch::setPaused(bool paused)
2✔
172
{
173
    if (m_paused == paused)
2✔
174
        return;
×
175

176
    m_paused = paused;
2✔
177

178
    if (m_pauseBuffer.length())
2✔
179
        m_pauseBuffer.clear();
1✔
180

181
    emit pausedChanged(m_paused);
2✔
182
}
183

184
bool OutputPatch::blackout() const
24,790✔
185
{
186
    return m_blackout;
24,790✔
187
}
188

189
void OutputPatch::setBlackout(bool blackout)
12✔
190
{
191
    if (m_blackout == blackout)
12✔
192
        return;
×
193

194
    m_blackout = blackout;
12✔
195
    emit blackoutChanged(m_blackout);
12✔
196
}
197

198
void OutputPatch::dump(quint32 universe, const QByteArray& data, bool dataChanged)
24,794✔
199
{
200
    /* Don't do anything if there is no plugin and/or output line. */
201
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
24,794✔
202
    {
203
        if (m_paused)
24,794✔
204
        {
205
            if (m_pauseBuffer.isNull())
2✔
206
                m_pauseBuffer.append(data);
1✔
207

208
            m_plugin->writeUniverse(universe, m_pluginLine, m_pauseBuffer, dataChanged);
2✔
209
        }
210
        else
211
        {
212
            m_plugin->writeUniverse(universe, m_pluginLine, data, dataChanged);
24,792✔
213
        }
214
    }
215
}
24,794✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc