From a2ad510b44017f9b6290eb3d22cacdb1e1732128 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 17 Feb 2010 10:24:46 +0100 Subject: Please, don't crash on CTRL+W signals :) BUG:227323 --- src/mainwindow.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 48d89f49..5237a20d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1052,27 +1052,33 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) m_popup->layout()->setMargin(margin); // useful values - + WebTab *tab = m_view->currentWebTab(); + + // fix crash on window close + if(!tab) + return; + // fix crash on window close - if(!m_view->currentWebTab()->page()->currentFrame()) + if(!tab->page()) return; - bool scrollbarIsVisible = m_view->currentWebTab()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); + bool scrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); int scrollbarSize = 0; if (scrollbarIsVisible) { //TODO: detect QStyle size scrollbarSize = 17; } - QPoint webViewOrigin = m_view->currentWebTab()->view()->mapToGlobal(QPoint(0,0)); - int bottomLeftY=webViewOrigin.y() + m_view->currentWebTab()->page()->viewportSize().height() - labelSize.height() - scrollbarSize; + + QPoint webViewOrigin = tab->view()->mapToGlobal(QPoint(0,0)); + int bottomLeftY = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - scrollbarSize; // setting popup in bottom-left position int x = geometry().x(); int y = bottomLeftY; - QPoint mousePos = m_view->currentWebTab()->mapToGlobal(m_view->currentWebTab()->view()->mousePos()); - if(QRect(webViewOrigin.x(),bottomLeftY,labelSize.width(),labelSize.height()).contains(mousePos)) + QPoint mousePos = tab->mapToGlobal( tab->view()->mousePos() ); + if( QRect( webViewOrigin.x() , bottomLeftY , labelSize.width() , labelSize.height() ).contains(mousePos) ) { // setting popup above the mouse y = bottomLeftY - labelSize.height(); -- cgit v1.2.1