Skip to content
Snippets Groups Projects
Commit f6870581 authored by Aurindam Jana's avatar Aurindam Jana Committed by Kai Koehne
Browse files

ScriptConsole: Crash FIX


Disconnect signals and slots when resetting QtMessageLogHandler.

Change-Id: I1a034c302b8e06f32b4bb2c5eaecae71488c5062
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent dc67ea92
No related branches found
No related tags found
No related merge requests found
...@@ -211,22 +211,43 @@ void QtMessageLogWindow::writeSettings() const ...@@ -211,22 +211,43 @@ void QtMessageLogWindow::writeSettings() const
void QtMessageLogWindow::setModel(QAbstractItemModel *model) void QtMessageLogWindow::setModel(QAbstractItemModel *model)
{ {
m_proxyModel->setSourceModel(model); QtMessageLogHandler *oldHandler = qobject_cast<QtMessageLogHandler *>(
QtMessageLogHandler *handler = qobject_cast<QtMessageLogHandler *>(model); m_proxyModel->sourceModel());
m_itemDelegate->setItemModel(handler); if (oldHandler) {
connect(m_clearAction, SIGNAL(triggered()), handler, SLOT(clear())); disconnect(m_clearAction, SIGNAL(triggered()), oldHandler, SLOT(clear()));
connect(handler, disconnect(oldHandler,
SIGNAL(selectEditableRow(QModelIndex,QItemSelectionModel::SelectionFlags)), SIGNAL(selectEditableRow(
m_proxyModel, QModelIndex,QItemSelectionModel::SelectionFlags)),
SLOT(selectEditableRow(QModelIndex,QItemSelectionModel::SelectionFlags))); m_proxyModel,
SLOT(selectEditableRow(
//Scroll to bottom when rows matching current filter settings are inserted QModelIndex,QItemSelectionModel::SelectionFlags)));
//Not connecting rowsRemoved as the only way to remove rows is to clear the disconnect(oldHandler,
//model which will automatically reset the view. SIGNAL(rowsInserted(QModelIndex,int,int)),
connect(handler, m_proxyModel,
SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(onRowsInserted(QModelIndex,int,int)));
m_proxyModel, }
SLOT(onRowsInserted(QModelIndex,int,int)));
QtMessageLogHandler *newHandler = qobject_cast<QtMessageLogHandler *>(model);
m_proxyModel->setSourceModel(newHandler);
m_itemDelegate->setItemModel(newHandler);
if (newHandler) {
connect(m_clearAction, SIGNAL(triggered()), newHandler, SLOT(clear()));
connect(newHandler,
SIGNAL(selectEditableRow(
QModelIndex,QItemSelectionModel::SelectionFlags)),
m_proxyModel,
SLOT(selectEditableRow(
QModelIndex,QItemSelectionModel::SelectionFlags)));
//Scroll to bottom when rows matching current filter settings are inserted
//Not connecting rowsRemoved as the only way to remove rows is to clear the
//model which will automatically reset the view.
connect(newHandler,
SIGNAL(rowsInserted(QModelIndex,int,int)),
m_proxyModel,
SLOT(onRowsInserted(QModelIndex,int,int)));
}
} }
} // namespace Internal } // namespace Internal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment