mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[Fix] Fixed occasional crash when closing tabs/windows. Closes #143
- disconnecting all signals/slots from widgets before deleting them to prevent invoking slots on deleted objects.
This commit is contained in:
parent
030d1b8c08
commit
8a88bdcc2d
@ -1484,9 +1484,28 @@ void QupZilla::closeEvent(QCloseEvent* event)
|
||||
}
|
||||
#endif
|
||||
|
||||
disconnectAllWidgets();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void QupZilla::disconnectAllWidgets()
|
||||
{
|
||||
// Disconnecting all important widgets before deleting this window
|
||||
// so it cannot happen that slots will be invoked after the object
|
||||
// is deleted.
|
||||
// We have to do it this way, because ~QObject is deleting all child
|
||||
// objects with plain delete - not deleteLater().
|
||||
|
||||
disconnect();
|
||||
m_tabWidget->disconnect();
|
||||
m_tabWidget->getTabBar()->disconnect();
|
||||
|
||||
foreach(WebTab * tab, m_tabWidget->allTabs()) {
|
||||
WebView* view = tab->view();
|
||||
view->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
bool QupZilla::quitApp()
|
||||
{
|
||||
if (m_sideBar.data()) {
|
||||
|
@ -210,9 +210,10 @@ private:
|
||||
|
||||
void setupUi();
|
||||
void setupMenu();
|
||||
|
||||
void addSideBar();
|
||||
|
||||
void disconnectAllWidgets();
|
||||
|
||||
bool m_historyMenuChanged;
|
||||
bool m_bookmarksMenuChanged;
|
||||
bool m_isClosing;
|
||||
|
@ -354,6 +354,7 @@ void TabWidget::closeTab(int index)
|
||||
tabBar()->setVisible(false);
|
||||
}
|
||||
|
||||
widget(index)->disconnect();
|
||||
widget(index)->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -388,6 +388,9 @@ TabWidget* WebView::tabWidget() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: Don't do this magic to get index of tab.
|
||||
// Implement setTabIndex() and call it from TabWidget (when creating and also from
|
||||
// tabMoved slot)
|
||||
int WebView::tabIndex() const
|
||||
{
|
||||
TabWidget* tabWid = tabWidget();
|
||||
@ -396,7 +399,10 @@ int WebView::tabIndex() const
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (qobject_cast<WebTab*>(tabWid->widget(i))->view() != this) {
|
||||
while (WebTab* wTab = qobject_cast<WebTab*>(tabWid->widget(i))) {
|
||||
if (wTab && wTab->view() == this) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
@ -1103,4 +1109,5 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
|
||||
|
||||
WebView::~WebView()
|
||||
{
|
||||
m_page->triggerAction(QWebPage::Stop);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user