2021-09-21 Fred Gleason <fredg@paravelsystems.com>

* Refactored 'RDMacroEvent' to avoid use of the STL.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2021-09-21 12:41:08 -04:00
parent bf1d015cb4
commit df3ad659fd
3 changed files with 16 additions and 18 deletions

View File

@ -22453,3 +22453,5 @@
2021-09-21 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in rdlibrary(1) that failed to update the
length of macro carts after editing.
2021-09-21 Fred Gleason <fredg@paravelsystems.com>
* Refactored 'RDMacroEvent' to avoid use of the STL.

View File

@ -55,7 +55,7 @@ RDMacroEvent::RDMacroEvent(QHostAddress addr,RDRipc *ripc,QObject *parent)
RDMacroEvent::~RDMacroEvent()
{
for(unsigned i=0;i<event_cmds.size();i++) {
for(int i=0;i<event_cmds.size();i++) {
delete event_cmds[i];
}
}
@ -100,7 +100,8 @@ int RDMacroEvent::size() const
unsigned RDMacroEvent::length() const
{
unsigned length=0;
for(unsigned i=0;i<event_cmds.size();i++) {
for(int i=0;i<event_cmds.size();i++) {
length+=event_cmds[i]->length();
}
return length;
@ -127,6 +128,7 @@ bool RDMacroEvent::load(const QString &str)
rmlstr="";
}
}
return true;
}
@ -152,7 +154,7 @@ QString RDMacroEvent::save()
{
QString str="";
for(unsigned i=0;i<event_cmds.size();i++) {
for(int i=0;i<event_cmds.size();i++) {
str+=event_cmds[i]->toString();
}
return str;
@ -161,18 +163,13 @@ QString RDMacroEvent::save()
void RDMacroEvent::insert(int line,const RDMacro *cmd)
{
std::vector<RDMacro *>::iterator it=event_cmds.begin()+line;
event_cmds.insert(it,1,new RDMacro(*cmd));
event_cmds.insert(line,new RDMacro(*cmd));
}
void RDMacroEvent::remove(int line)
{
std::vector<RDMacro *>::iterator it=event_cmds.begin()+line;
delete event_cmds[line];
event_cmds.erase(it,it+1);
event_cmds.removeAt(line);
}
@ -314,7 +311,7 @@ void RDMacroEvent::ExecList(int line)
event_whole_list=true;
emit started();
}
for(unsigned i=line;i<event_cmds.size();i++) {
for(int i=line;i<event_cmds.size();i++) {
switch(event_cmds[i]->command()) {
case RDMacro::SP: // Sleep
exec(i);

View File

@ -21,12 +21,11 @@
#ifndef RDMACRO_EVENT_H
#define RDMACRO_EVENT_H
#include <vector>
#include <qobject.h>
#include <qtimer.h>
#include <qhostaddress.h>
#include <qdatetime.h>
#include <QDateTime>
#include <QHostAddress>
#include <QList>
#include <QObject>
#include <QTimer>
#include <rdmacro.h>
#include <rdripc.h>
@ -71,7 +70,7 @@ class RDMacroEvent : public QObject
private:
void ExecList(int line);
std::vector<RDMacro *> event_cmds;
QList<RDMacro *> event_cmds;
RDRipc *event_ripc;
QTimer *event_sleep_timer;
bool event_whole_list;