forked from qt-creator/qt-creator
ScriptConsole: Crash FIX
Disconnect signals and slots when resetting QtMessageLogHandler. Change-Id: I1a034c302b8e06f32b4bb2c5eaecae71488c5062 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
committed by
Kai Koehne
parent
dc67ea9292
commit
f6870581e4
@@ -211,22 +211,43 @@ void QtMessageLogWindow::writeSettings() const
|
||||
|
||||
void QtMessageLogWindow::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
m_proxyModel->setSourceModel(model);
|
||||
QtMessageLogHandler *handler = qobject_cast<QtMessageLogHandler *>(model);
|
||||
m_itemDelegate->setItemModel(handler);
|
||||
connect(m_clearAction, SIGNAL(triggered()), handler, SLOT(clear()));
|
||||
connect(handler,
|
||||
SIGNAL(selectEditableRow(QModelIndex,QItemSelectionModel::SelectionFlags)),
|
||||
m_proxyModel,
|
||||
SLOT(selectEditableRow(QModelIndex,QItemSelectionModel::SelectionFlags)));
|
||||
QtMessageLogHandler *oldHandler = qobject_cast<QtMessageLogHandler *>(
|
||||
m_proxyModel->sourceModel());
|
||||
if (oldHandler) {
|
||||
disconnect(m_clearAction, SIGNAL(triggered()), oldHandler, SLOT(clear()));
|
||||
disconnect(oldHandler,
|
||||
SIGNAL(selectEditableRow(
|
||||
QModelIndex,QItemSelectionModel::SelectionFlags)),
|
||||
m_proxyModel,
|
||||
SLOT(selectEditableRow(
|
||||
QModelIndex,QItemSelectionModel::SelectionFlags)));
|
||||
disconnect(oldHandler,
|
||||
SIGNAL(rowsInserted(QModelIndex,int,int)),
|
||||
m_proxyModel,
|
||||
SLOT(onRowsInserted(QModelIndex,int,int)));
|
||||
}
|
||||
|
||||
//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(handler,
|
||||
SIGNAL(rowsInserted(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
|
||||
|
||||
Reference in New Issue
Block a user