summaryrefslogtreecommitdiff
path: root/src/webwindow
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-08-05 14:12:47 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:04 +0100
commit6b82ad9b2c7ed5af633e972ea2b56e3a30886d20 (patch)
tree8460d365f4e342ff1ccd8a88dd910bc628d13984 /src/webwindow
parentlink hovered messages restored :) (diff)
downloadrekonq-6b82ad9b2c7ed5af633e972ea2b56e3a30886d20.tar.xz
Ensure Rekonq (tools) menu does not crash by using a Q(Weak)Pointer
Diffstat (limited to 'src/webwindow')
-rw-r--r--src/webwindow/rekonqmenu.cpp12
-rw-r--r--src/webwindow/rekonqmenu.h5
2 files changed, 12 insertions, 5 deletions
diff --git a/src/webwindow/rekonqmenu.cpp b/src/webwindow/rekonqmenu.cpp
index a5cea784..c32d71f5 100644
--- a/src/webwindow/rekonqmenu.cpp
+++ b/src/webwindow/rekonqmenu.cpp
@@ -51,20 +51,24 @@ void RekonqMenu::showEvent(QShowEvent* event)
{
KMenu::showEvent(event);
- if (!m_button)
+ if (m_button.isNull())
return;
+ kDebug() << "but: " << m_button.data();
+ kDebug() << "but w: " << m_button.data()->width();
+ kDebug() << "but h: " << m_button.data()->height();
+
// Adjust the position of the menu to be shown within the
// rekonq window to reduce the cases that sub-menus might overlap
// the right screen border.
QPoint pos;
if (layoutDirection() == Qt::RightToLeft)
{
- pos = m_button->mapToGlobal(QPoint(0, m_button->height()));
+ pos = m_button.data()->mapToGlobal(QPoint(0, m_button.data()->height()));
}
else
{
- pos = m_button->mapToGlobal(QPoint(m_button->width(), m_button->height()));
+ pos = m_button.data()->mapToGlobal(QPoint(m_button.data()->width(), m_button.data()->height()));
pos.rx() -= width();
}
@@ -91,7 +95,7 @@ void RekonqMenu::showEvent(QShowEvent* event)
{
if (pos.y() + height() > screen.y() + screen.height())
{
- pos.ry() = m_button->mapToGlobal(QPoint(0, 0)).y() + height();
+ pos.ry() = m_button.data()->mapToGlobal(QPoint(0, 0)).y() + height();
}
}
diff --git a/src/webwindow/rekonqmenu.h b/src/webwindow/rekonqmenu.h
index 8bda008b..24aaba91 100644
--- a/src/webwindow/rekonqmenu.h
+++ b/src/webwindow/rekonqmenu.h
@@ -36,6 +36,9 @@
// KDE Includes
#include <KMenu>
+// Qt Includes
+#include <QWeakPointer>
+
// Forward Declarations
class QWidget;
@@ -58,7 +61,7 @@ protected:
virtual void showEvent(QShowEvent* event);
private:
- QWidget *m_button;
+ QWeakPointer<QWidget> m_button;
};
#endif // REKONQ_MENU_H