My class "ComponentArea" looks like this:
#ifndef COMPONENTAREA_H
#define COMPONENTAREA_H
#include <QObject>
#include <QWidget>
#include <QScrollArea>
#include <QtDesigner/QtDesigner>
#include <QMouseEvent>
#include <QPainter>
#include <Components/Sockets/socket.h>
class Socket;
class ComponentArea : public QScrollArea
{
Q_OBJECT
public:
ComponentArea(QWidget* parent);
void connectSockets(Socket* a, Socket* b);
void childBlock_childSocket_mousePressEvent(Socket* sender, QMouseEvent* event);
void childBlock_childSocket_mouseReleaseEvent(Socket* sender, QMouseEvent* event);
private:
Socket* pressedSocket;
void mouseReleaseEvent(QMouseEvent *event);
};
#endif // COMPONENTAREA_H
In the constructor, I set pressedSocket to 0:
pressedSocket = 0;
Whenever I try to use pressedSocket, in one of the events, I get a Segmentation Fault:
void ComponentArea::childBlock_childSocket_mousePressEvent(Socket *sender, QMouseEvent *event)
{
if((pressedSocket == 0) && (event->button() == Qt::LeftButton)) {
pressedSocket = sender;
}
}
When I try to inspect pressedSocket at this line, the Debugger tells me "pressedSocket <no such value>".
I don't see what I am doing wrong. Any advices? Thanks in advance!