PDA

View Full Version : slot won´t be called (d3lphin debugging)



sirwitti
29th June 2008, 20:39
hello!
since i found some serious and annoying bugs in dolphin (kde3) and nobody seems to work on them i decided to do it myself.
the problem i have right now is that one slot (updateNavigatorURL()) that is connected to a signal (clicked()) won´t be executed, although the connect statement returns true.
in the original code this worked of course, but since i had to change the (quite poor) design i couldn´t work out the problem by comparing the codes (although i tried). well actually i couldn´t even find out what exactly the problem is... :(
so hopefully here´s someone who´s able to help me out with this one, since i´m new to qt/kde development.
should not be too hard to find for someone with more experience than me.
great thanks in advance, witti

urlnavigatorbutton.h:


...
class URLNavigatorButton : public URLButton
{
Q_OBJECT

public:
URLNavigatorButton(URLNavigator* parent = 0);
URLNavigatorButton(int index, URLNavigator* parent = 0);
virtual ~URLNavigatorButton();
void setIndex(int index);
int index() const;
bool isLastButton();

protected:
virtual void drawButton(QPainter* painter);
virtual void enterEvent(QEvent* event);
virtual void leaveEvent(QEvent* event);
//drag
void mousePressEvent( QMouseEvent *event );
void mouseMoveEvent( QMouseEvent *event );
//drop
virtual void dropEvent(QDropEvent* event);
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dragLeaveEvent(QDragLeaveEvent* event);

private slots:
void updateNavigatorURL();
void startPopupDelay();
void stopPopupDelay();
void startListJob();
void entriesList(KIO::Job* job, const KIO::UDSEntryList& entries);
void listJobFinished(KIO::Job* job);
...



urlnavigatorbutton.cpp:


...
URLNavigatorButton::URLNavigatorButton(int index, URLNavigator* parent) :
URLButton(parent),
m_index(-1),
m_listJob(0)
{
setAcceptDrops(true);
setMinimumWidth(arrowWidth());
setIndex(index);
connect(this, SIGNAL(clicked()), this, SLOT(updateNavigatorURL()));

m_popupDelay = new QTimer(this);
connect(m_popupDelay, SIGNAL(timeout()), this, SLOT(startListJob()));
connect(this, SIGNAL(pressed()), this, SLOT(startPopupDelay()));
}
...
void URLNavigatorButton::updateNavigatorURL()
{
URLNavigator* navigator = urlNavigator();
assert(navigator != 0);
navigator->setURL(navigator->url(m_index));
}

jacek
29th June 2008, 23:19
You have reimplemented the mousePressEvent(). Are you sure that the clicked() signal is emitted?

sirwitti
29th June 2008, 23:56
hm, the connect(...) returns true. is there another way of testing, whether the clicked() signal is emitted?

jacek
30th June 2008, 00:20
hm, the connect(...) returns true. is there another way of testing, whether the clicked() signal is emitted?
Checking the return value of connect() doesn't test whether the signal is emitter or not. It just says whether the connection was succesful or not. Connect that signal to QApplication::about() or set a breakpoint on URLNavigatorButton::clicked().

sirwitti
30th June 2008, 00:31
nothing happens when connecting it to QApplication:about() and another custom slot i tried is not called either.
so the clicked() signal is not called i guess?!
well as it seems i have to go the hard way, meaning that i´ll start over with the original source and step by step apply my changes.
or is theren anything else i could do?
btw thanks a lot jacek :)
witti

jacek
30th June 2008, 00:35
or is theren anything else i could do?
Check URLNavigatorButton::mousePressEvent(). If you don't call the base class implementation (or QPushButton::mousePressEvent()), QPushButton isn't going to know it has been clicked.

sirwitti
30th June 2008, 00:51
i checked this already, it seems ok to me. URLButton is the parent class of URLNavigatorbutton and is a direct child of QPushbutton.
In the URLButton class the mouspressedEvent() is not implemented, so the implementation of QPushbutton should be called.
URLNavigatorButton::mousePressEvent is being called...


void URLNavigatorButton::mousePressEvent(QMouseEvent * event)
{
if (event->button() == LeftButton)
dragPos = event->pos();
URLButton::mousePressEvent(event);
}

so thats not the problem i think.
any other options?
thx, witti

sirwitti
30th June 2008, 00:58
omg it was just that "qApp" instead of "this" in the connect statement.
its always the simple things that aren´t simple at all. ;-)
thank you very much jacek
witti