Permalink
Browse files

ui/simple desk: optimize CPU usage by considering the changed flag

  • Loading branch information...
mcallegari committed Dec 24, 2018
1 parent 58b1684 commit 36a65c3a6d268781a4ec5e583730c365fe0a3e35
Showing with 21 additions and 20 deletions.
  1. +1 −1 engine/src/dmxsource.h
  2. +15 −15 ui/src/simpledesk.cpp
  3. +5 −4 ui/src/simpledeskengine.cpp
@@ -48,7 +48,7 @@ class DMXSource

/** Get/Set if the DMX source has changed */
bool hasChanged() { return m_changed; }
void setChanged() { m_changed = true; }
void setChanged(bool changed) { m_changed = changed; }

protected:
bool m_changed;
@@ -858,7 +858,7 @@ void SimpleDesk::slotAliasChanged()
void SimpleDesk::slotUniverseSliderValueChanged(quint32 fid, quint32 chan, uchar value)
{
QVariant var(sender()->property(PROP_ADDRESS));
if (var.isValid() == true) // Not true with disabled sliders
if (var.isValid()) // Not true with disabled sliders
{
quint32 chanAbsAddr = var.toUInt();
if (m_viewModeButton->isChecked() == false &&
@@ -879,24 +879,24 @@ void SimpleDesk::slotUniverseSliderValueChanged(quint32 fid, quint32 chan, uchar
else // calculate the absolute address from the given parameters
{
Fixture *fixture = m_doc->fixture(fid);
if (fixture != NULL)
if (fixture == NULL)
return;

quint32 chanAbsAddr = fixture->universeAddress() + chan;
if (m_viewModeButton->isChecked() == true &&
m_engine->hasChannel(chanAbsAddr) == false)
{
quint32 chanAbsAddr = fixture->universeAddress() + chan;
if (m_viewModeButton->isChecked() == true &&
m_engine->hasChannel(chanAbsAddr) == false)
if (m_consoleList.contains(fid))
{
if (m_consoleList.contains(fid))
{
FixtureConsole *fc = m_consoleList[fid];
if (fc != NULL)
fc->setChannelStylesheet(chan, ssOverride);
}
FixtureConsole *fc = m_consoleList[fid];
if (fc != NULL)
fc->setChannelStylesheet(chan, ssOverride);
}
m_engine->setValue(chanAbsAddr, value);

if (m_editCueStackButton->isChecked() == true)
replaceCurrentCue();
}
m_engine->setValue(chanAbsAddr, value);

if (m_editCueStackButton->isChecked() == true)
replaceCurrentCue();
}
}

@@ -83,7 +83,7 @@ void SimpleDeskEngine::setValue(uint channel, uchar value)

QMutexLocker locker(&m_mutex);
m_values[channel] = value;
setChanged();
setChanged(true);
}

uchar SimpleDeskEngine::value(uint channel) const
@@ -107,7 +107,7 @@ void SimpleDeskEngine::setCue(const Cue& cue)

QMutexLocker locker(&m_mutex);
m_values = cue.values();
setChanged();
setChanged(true);
}

Cue SimpleDeskEngine::cue() const
@@ -133,7 +133,7 @@ void SimpleDeskEngine::resetUniverse(int universe)

// add command to queue. Will be taken care of at the next writeDMX call
m_commandQueue.append(QPair<int,quint32>(ResetUniverse, universe));
setChanged();
setChanged(true);
}

void SimpleDeskEngine::resetChannel(uint channel)
@@ -144,7 +144,7 @@ void SimpleDeskEngine::resetChannel(uint channel)

// add command to queue. Will be taken care of at the next writeDMX call
m_commandQueue.append(QPair<int,quint32>(ResetChannel, channel));
setChanged();
setChanged(true);
}

/****************************************************************************
@@ -375,6 +375,7 @@ void SimpleDeskEngine::writeDMX(MasterTimer *timer, QList<Universe *> ua)
fc->setTarget(value);
fc->setTypeFlag(FadeChannel::Override);
}
setChanged(false);
}

foreach (CueStack *cueStack, m_cueStacks)

0 comments on commit 36a65c3

Please sign in to comment.