Fix Warnings in MouseEventFilter.cpp

/retroshare-gui/src/util/MouseEventFilter.cpp:56: warning: catching
polymorphic type 'class std::bad_cast' by value [-Wcatch-value=]
/retroshare-gui/src/util/MouseEventFilter.cpp:77: warning: catching
polymorphic type 'class std::bad_cast' by value [-Wcatch-value=]
This commit is contained in:
Phenom 2018-10-08 19:27:48 +02:00
parent da6778934d
commit a30e2c3400

View File

@ -17,90 +17,90 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <util/MouseEventFilter.h>
#include <QEvent>
#include <QMouseEvent>
#include <exception>
#include <typeinfo>
MouseMoveEventFilter::MouseMoveEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseMoveEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseMove) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}
MousePressEventFilter::MousePressEventFilter(QObject * receiver, const char * member, Qt::MouseButton button)
: EventFilter(receiver, member),
_button(button) {
}
bool MousePressEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseButtonPress) {
try {
QMouseEvent * mouseEvent = dynamic_cast<QMouseEvent *>(event);
if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) {
filter(event);
return false;
}
} catch (std::bad_cast) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}
return EventFilter::eventFilter(watched, event);
}
MouseReleaseEventFilter::MouseReleaseEventFilter(QObject * receiver, const char * member, Qt::MouseButton button)
: EventFilter(receiver, member),
_button(button) {
}
bool MouseReleaseEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseButtonRelease) {
try {
QMouseEvent * mouseEvent = dynamic_cast<QMouseEvent *>(event);
if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) {
filter(event);
return false;
}
} catch (std::bad_cast) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}
return EventFilter::eventFilter(watched, event);
}
MouseHoverEnterEventFilter::MouseHoverEnterEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseHoverEnterEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::HoverEnter) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}
MouseHoverLeaveEventFilter::MouseHoverLeaveEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseHoverLeaveEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::HoverLeave) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}
****************************************************************/
#include <util/MouseEventFilter.h>
#include <QEvent>
#include <QMouseEvent>
#include <exception>
#include <typeinfo>
MouseMoveEventFilter::MouseMoveEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseMoveEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseMove) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}
MousePressEventFilter::MousePressEventFilter(QObject * receiver, const char * member, Qt::MouseButton button)
: EventFilter(receiver, member),
_button(button) {
}
bool MousePressEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseButtonPress) {
try {
QMouseEvent * mouseEvent = dynamic_cast<QMouseEvent *>(event);
if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) {
filter(event);
return false;
}
} catch (const std::bad_cast&) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}
return EventFilter::eventFilter(watched, event);
}
MouseReleaseEventFilter::MouseReleaseEventFilter(QObject * receiver, const char * member, Qt::MouseButton button)
: EventFilter(receiver, member),
_button(button) {
}
bool MouseReleaseEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::MouseButtonRelease) {
try {
QMouseEvent * mouseEvent = dynamic_cast<QMouseEvent *>(event);
if ((_button == Qt::NoButton) || (mouseEvent->button() == _button)) {
filter(event);
return false;
}
} catch (const std::bad_cast&) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}
return EventFilter::eventFilter(watched, event);
}
MouseHoverEnterEventFilter::MouseHoverEnterEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseHoverEnterEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::HoverEnter) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}
MouseHoverLeaveEventFilter::MouseHoverLeaveEventFilter(QObject * receiver, const char * member)
: EventFilter(receiver, member) {
}
bool MouseHoverLeaveEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (event->type() == QEvent::HoverLeave) {
filter(event);
return false;
}
return EventFilter::eventFilter(watched, event);
}