Fixed a bunch of memory leaks - thanks to the superb Valgrind!
This commit is contained in:
parent
984d65b27d
commit
c97ae3bc55
@ -22,6 +22,8 @@ Port::Port(quint32 id, quint32 portGroupId)
|
||||
|
||||
Port::~Port()
|
||||
{
|
||||
while (!mStreams.isEmpty())
|
||||
delete mStreams.takeFirst();
|
||||
}
|
||||
|
||||
void Port::updatePortConfig(OstProto::Port *port)
|
||||
|
@ -13,6 +13,7 @@ class Port : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
static uint mAllocStreamId;
|
||||
|
||||
OstProto::Port d;
|
||||
OstProto::PortStats stats;
|
||||
|
||||
|
@ -23,8 +23,7 @@ PortGroup::PortGroup(QHostAddress ip, quint16 port)
|
||||
rpcController = new PbRpcController;
|
||||
rpcControllerStats = new PbRpcController;
|
||||
isGetStatsPending_ = false;
|
||||
serviceStub = new OstProto::OstService::Stub(rpcChannel,
|
||||
OstProto::OstService::STUB_OWNS_CHANNEL);
|
||||
serviceStub = new OstProto::OstService::Stub(rpcChannel);
|
||||
|
||||
// FIXME(LOW):Can't for my life figure out why this ain't working!
|
||||
//QMetaObject::connectSlotsByName(this);
|
||||
@ -44,6 +43,9 @@ PortGroup::~PortGroup()
|
||||
// Disconnect and free rpc channel etc.
|
||||
PortGroup::disconnectFromHost();
|
||||
delete serviceStub;
|
||||
delete rpcControllerStats;
|
||||
delete rpcController;
|
||||
delete rpcChannel;
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,15 +11,25 @@ PortGroupList::PortGroupList()
|
||||
PortGroup *pg;
|
||||
|
||||
// TODO(LOW): Remove
|
||||
new ModelTest(getStreamModel());
|
||||
new ModelTest(getPortModel());
|
||||
new ModelTest(getPortStatsModel());
|
||||
streamModelTester_ = new ModelTest(getStreamModel());
|
||||
portModelTester_ = new ModelTest(getPortModel());
|
||||
portStatsModelTester_ = new ModelTest(getPortStatsModel());
|
||||
|
||||
// Add the "Local" Port Group
|
||||
pg = new PortGroup;
|
||||
addPortGroup(*pg);
|
||||
}
|
||||
|
||||
PortGroupList::~PortGroupList()
|
||||
{
|
||||
while (!mPortGroups.isEmpty())
|
||||
delete mPortGroups.takeFirst();
|
||||
|
||||
delete portStatsModelTester_;
|
||||
delete portModelTester_;
|
||||
delete streamModelTester_;
|
||||
}
|
||||
|
||||
bool PortGroupList::isPortGroup(const QModelIndex& index)
|
||||
{
|
||||
return mPortGroupListModel.isPortGroup(index);
|
||||
|
@ -24,10 +24,14 @@ class PortGroupList : public QObject {
|
||||
StreamModel mStreamListModel;
|
||||
PortStatsModel mPortStatsModel;
|
||||
|
||||
QObject *streamModelTester_;
|
||||
QObject *portModelTester_;
|
||||
QObject *portStatsModelTester_;
|
||||
|
||||
// Methods
|
||||
public:
|
||||
PortGroupList();
|
||||
|
||||
~PortGroupList();
|
||||
|
||||
PortModel* getPortModel() { return &mPortGroupListModel; }
|
||||
PortStatsModel* getPortStatsModel() { return &mPortStatsModel; }
|
||||
|
@ -6,8 +6,6 @@
|
||||
PortStatsModel::PortStatsModel(PortGroupList *p, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
QTimer *timer;
|
||||
|
||||
pgl = p;
|
||||
|
||||
timer = new QTimer();
|
||||
@ -15,6 +13,12 @@ PortStatsModel::PortStatsModel(PortGroupList *p, QObject *parent)
|
||||
timer->start(1000);
|
||||
}
|
||||
|
||||
PortStatsModel::~PortStatsModel()
|
||||
{
|
||||
timer->stop();
|
||||
delete timer;
|
||||
}
|
||||
|
||||
int PortStatsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <QAbstractTableModel>
|
||||
#include <QStringList>
|
||||
|
||||
class QTimer;
|
||||
|
||||
typedef enum {
|
||||
// State
|
||||
e_STATE_START = 0,
|
||||
@ -78,6 +80,7 @@ class PortStatsModel : public QAbstractTableModel
|
||||
public:
|
||||
|
||||
PortStatsModel(PortGroupList *p, QObject *parent = 0);
|
||||
~PortStatsModel();
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
@ -109,6 +112,8 @@ class PortStatsModel : public QAbstractTableModel
|
||||
// Also it stores them as cumulative totals
|
||||
QList<quint16> numPorts;
|
||||
|
||||
QTimer *timer;
|
||||
|
||||
void getDomainIndexes(const QModelIndex &index,
|
||||
uint &portGroupIdx, uint &portIdx) const;
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
#include "portswindow.h"
|
||||
#include "streamlistdelegate.h"
|
||||
#include "streamconfigdialog.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QItemSelectionModel>
|
||||
|
||||
#include "streamconfigdialog.h"
|
||||
#include "streamlistdelegate.h"
|
||||
|
||||
PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
StreamListDelegate *delegate = new StreamListDelegate;
|
||||
delegate = new StreamListDelegate;
|
||||
//slm = new StreamListModel();
|
||||
//plm = new PortGroupList();
|
||||
plm = pgl;
|
||||
@ -72,6 +74,7 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
|
||||
PortsWindow::~PortsWindow()
|
||||
{
|
||||
delete delegate;
|
||||
}
|
||||
|
||||
void PortsWindow::on_tvStreamList_activated(const QModelIndex & index)
|
||||
|
@ -12,6 +12,7 @@ MED
|
||||
LOW
|
||||
*/
|
||||
|
||||
class QAbstractItemDelegate;
|
||||
|
||||
class PortsWindow : public QWidget, private Ui::PortsWindow
|
||||
{
|
||||
@ -26,6 +27,7 @@ public:
|
||||
|
||||
private:
|
||||
QString lastNewPortGroup;
|
||||
QAbstractItemDelegate *delegate;
|
||||
|
||||
void updatePortViewActions(const QModelIndex& current);
|
||||
//void updateStreamViewActions(const QModelIndex& current);
|
||||
|
@ -62,6 +62,16 @@ ProtocolManager::ProtocolManager()
|
||||
populateNeighbourProtocols();
|
||||
}
|
||||
|
||||
ProtocolManager::~ProtocolManager()
|
||||
{
|
||||
numberToNameMap.clear();
|
||||
nameToNumberMap.clear();
|
||||
neighbourProtocols.clear();
|
||||
factory.clear();
|
||||
while (!protocolList.isEmpty())
|
||||
delete protocolList.takeFirst();
|
||||
}
|
||||
|
||||
void ProtocolManager::registerProtocol(int protoNumber,
|
||||
void *protoInstanceCreator)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@ class ProtocolManager
|
||||
|
||||
public:
|
||||
ProtocolManager();
|
||||
~ProtocolManager();
|
||||
|
||||
void registerProtocol(int protoNumber, void *protoInstanceCreator);
|
||||
|
||||
|
@ -50,9 +50,11 @@ StreamBase::StreamBase() :
|
||||
|
||||
StreamBase::~StreamBase()
|
||||
{
|
||||
delete mStreamId;
|
||||
delete mCore;
|
||||
currentFrameProtocols->destroy();
|
||||
delete currentFrameProtocols;
|
||||
delete mControl;
|
||||
delete mCore;
|
||||
delete mStreamId;
|
||||
}
|
||||
|
||||
void StreamBase::protoDataCopyFrom(const OstProto::Stream &stream)
|
||||
|
@ -10,6 +10,7 @@ RpcServer::RpcServer()
|
||||
|
||||
isPending = false;
|
||||
pendingMethodId = -1; // don't care as long as isPending is false
|
||||
controller_.Reset();
|
||||
}
|
||||
|
||||
RpcServer::~RpcServer()
|
||||
@ -46,7 +47,8 @@ QString RpcServer::errorString()
|
||||
return errorString_;
|
||||
}
|
||||
|
||||
void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcController)
|
||||
void RpcServer::done(::google::protobuf::Message *request,
|
||||
::google::protobuf::Message *response)
|
||||
{
|
||||
QIODevice *blob;
|
||||
char msg[MSGBUF_SIZE];
|
||||
@ -54,13 +56,13 @@ void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcCo
|
||||
|
||||
//qDebug("In RpcServer::done");
|
||||
|
||||
if (PbRpcController->Failed())
|
||||
if (controller_.Failed())
|
||||
{
|
||||
qDebug("rpc failed");
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
blob = PbRpcController->binaryBlob();
|
||||
blob = controller_.binaryBlob();
|
||||
if (blob)
|
||||
{
|
||||
len = blob->size();
|
||||
@ -85,17 +87,17 @@ void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcCo
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (!resp->IsInitialized())
|
||||
if (!response->IsInitialized())
|
||||
{
|
||||
qWarning("response missing required fields!!");
|
||||
qDebug(resp->InitializationErrorString().c_str());
|
||||
qDebug(response->InitializationErrorString().c_str());
|
||||
qFatal("exiting");
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
resp->SerializeToArray((void*) &msg[PB_HDR_SIZE], sizeof(msg));
|
||||
response->SerializeToArray((void*) &msg[PB_HDR_SIZE], sizeof(msg));
|
||||
|
||||
len = resp->ByteSize();
|
||||
len = response->ByteSize();
|
||||
|
||||
*((quint16*)(&msg[0])) = HTONS(PB_MSG_TYPE_RESPONSE); // type
|
||||
*((quint16*)(&msg[2])) = HTONS(pendingMethodId); // method
|
||||
@ -105,14 +107,15 @@ void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcCo
|
||||
if (pendingMethodId != 12)
|
||||
{
|
||||
qDebug("Server(%s): sending %d bytes to client encoding <%s>",
|
||||
__FUNCTION__, len + PB_HDR_SIZE, resp->DebugString().c_str());
|
||||
__FUNCTION__, len + PB_HDR_SIZE, response->DebugString().c_str());
|
||||
//BUFDUMP(msg, len + 8);
|
||||
}
|
||||
|
||||
clientSock->write(msg, PB_HDR_SIZE + len);
|
||||
|
||||
_exit:
|
||||
delete PbRpcController;
|
||||
delete request;
|
||||
delete response;
|
||||
isPending = false;
|
||||
}
|
||||
|
||||
@ -173,7 +176,6 @@ void RpcServer::when_dataAvail()
|
||||
static quint32 len;
|
||||
const ::google::protobuf::MethodDescriptor *methodDesc;
|
||||
::google::protobuf::Message *req, *resp;
|
||||
PbRpcController *controller;
|
||||
|
||||
if (!parsing)
|
||||
{
|
||||
@ -238,12 +240,12 @@ void RpcServer::when_dataAvail()
|
||||
//qDebug("Server(%s): successfully parsed as <%s>", __FUNCTION__,
|
||||
//resp->DebugString().c_str());
|
||||
|
||||
controller = new PbRpcController;
|
||||
controller_.Reset();
|
||||
|
||||
//qDebug("before service->callmethod()");
|
||||
|
||||
service->CallMethod(methodDesc, controller, req, resp,
|
||||
NewCallback(this, &RpcServer::done, resp, controller));
|
||||
service->CallMethod(methodDesc, &controller_, req, resp,
|
||||
NewCallback(this, &RpcServer::done, req, resp));
|
||||
|
||||
parsing = false;
|
||||
|
||||
|
@ -23,6 +23,7 @@ class RpcServer : public QObject
|
||||
|
||||
bool isPending;
|
||||
int pendingMethodId;
|
||||
PbRpcController controller_;
|
||||
QString errorString_;
|
||||
|
||||
public:
|
||||
@ -32,7 +33,8 @@ public:
|
||||
bool registerService(::google::protobuf::Service *service,
|
||||
quint16 tcpPortNum);
|
||||
QString errorString();
|
||||
void done(::google::protobuf::Message *resp, PbRpcController *controller);
|
||||
void done(::google::protobuf::Message *req,
|
||||
::google::protobuf::Message *resp);
|
||||
|
||||
private slots:
|
||||
void when_newConnection();
|
||||
|
@ -20,6 +20,9 @@ Drone::Drone(QWidget *parent)
|
||||
Drone::~Drone()
|
||||
{
|
||||
trayIcon_->hide();
|
||||
|
||||
delete trayIcon_;
|
||||
delete trayIconMenu_;
|
||||
delete rpcServer;
|
||||
delete service;
|
||||
}
|
||||
|
@ -195,6 +195,12 @@ _open_error:
|
||||
usingInternalHandle_ = false;
|
||||
}
|
||||
|
||||
PcapPort::PortTransmitter::~PortTransmitter()
|
||||
{
|
||||
if (usingInternalStats_)
|
||||
delete stats_;
|
||||
}
|
||||
|
||||
void PcapPort::PortTransmitter::clearPacketList()
|
||||
{
|
||||
Q_ASSERT(!isRunning());
|
||||
|
@ -69,6 +69,7 @@ protected:
|
||||
{
|
||||
public:
|
||||
PortTransmitter(const char *device);
|
||||
~PortTransmitter();
|
||||
void clearPacketList();
|
||||
bool appendToPacketList(long sec, long usec, const uchar *packet,
|
||||
int length);
|
||||
|
@ -45,6 +45,8 @@ PortManager::PortManager()
|
||||
|
||||
PortManager::~PortManager()
|
||||
{
|
||||
while (!portList_.isEmpty())
|
||||
delete portList_.takeFirst();
|
||||
}
|
||||
|
||||
PortManager* PortManager::instance()
|
||||
|
@ -24,6 +24,8 @@ WinPcapPort::WinPcapPort(int id, const char *device)
|
||||
|
||||
WinPcapPort::~WinPcapPort()
|
||||
{
|
||||
delete monitorRx_;
|
||||
delete monitorTx_;
|
||||
}
|
||||
|
||||
OstProto::LinkState WinPcapPort::linkState()
|
||||
|
Loading…
Reference in New Issue
Block a user