Summary: | KDevelop crashes after pressing apply button in Find & Replace dialog, when no matches where found | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Chaos A.D. <chaos-ad> |
Component: | general | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 4.1.60 | ||
Target Milestone: | 4.2.0 | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdevplatform/26538cbadb56610f3c4c5f0f1e1b6ea5900a1353 | Version Fixed In: |
Description
Chaos A.D.
2010-12-01 18:31:53 UTC
> GrepOutputModel::doReplacements() does not check that root item has parents :)
children, not parents :-)
commit c6bdd0e59708195498598b0316b052d437b966fd branch master Author: Milian Wolff <mail@milianw.de> Date: Wed Dec 1 21:40:01 2010 +0100 make sure we don't try to apply / jump to prev/next item if we don't have any matches hide apply button when we only search for items BUG: 258504 diff --git a/plugins/grepview/grepoutputmodel.cpp b/plugins/grepview/grepoutputmodel.cpp index fd4f2aa..83268e6 100644 --- a/plugins/grepview/grepoutputmodel.cpp +++ b/plugins/grepview/grepoutputmodel.cpp @@ -312,7 +312,8 @@ void GrepOutputModel::updateCheckState(QStandardItem* item) void GrepOutputModel::doReplacements() { - + Q_ASSERT(m_rootItem); + DocumentChangeSet changeSet; changeSet.setFormatPolicy(DocumentChangeSet::NoAutoFormat); for(int fileRow = 0; fileRow < m_rootItem->rowCount(); fileRow++) diff --git a/plugins/grepview/grepoutputview.cpp b/plugins/grepview/grepoutputview.cpp index e02e255..d4ba5e0 100644 --- a/plugins/grepview/grepoutputview.cpp +++ b/plugins/grepview/grepoutputview.cpp @@ -48,25 +48,28 @@ GrepOutputView::GrepOutputView(QWidget* parent) setWindowIcon(SmallIcon("edit-find")); m_apply = new QAction(KIcon("dialog-ok-apply"), i18n("&Replace"), this); - QAction *previous = new QAction(KIcon("go-previous"), i18n("&Previous"), this); - QAction *next = new QAction(KIcon("go-next"), i18n("&Next"), this); + m_apply->setEnabled(false); + m_prev = new QAction(KIcon("go-previous"), i18n("&Previous"), this); + m_prev->setEnabled(false); + m_next = new QAction(KIcon("go-next"), i18n("&Next"), this); + m_next->setEnabled(false); QAction *separator = new QAction(this); separator->setSeparator(true); QAction *change_criteria = new QAction(KIcon("configure"), i18n("&Change criteria"), this); addAction(m_apply); - addAction(previous); - addAction(next); + addAction(m_prev); + addAction(m_next); addAction(separator); addAction(change_criteria); - resultsTreeView->setModel(new GrepOutputModel); + renewModel(); resultsTreeView->setItemDelegate(GrepOutputDelegate::self()); resultsTreeView->setHeaderHidden(true); - + connect(m_apply, SIGNAL(triggered(bool)), this, SLOT(onApply())); - connect(previous, SIGNAL(triggered(bool)), this, SLOT(selectPreviousItem())); - connect(next, SIGNAL(triggered(bool)), this, SLOT(selectNextItem())); + connect(m_prev, SIGNAL(triggered(bool)), this, SLOT(selectPreviousItem())); + connect(m_next, SIGNAL(triggered(bool)), this, SLOT(selectNextItem())); connect(change_criteria, SIGNAL(triggered(bool)), this, SLOT(showDialog())); } @@ -77,13 +80,17 @@ GrepOutputView::~GrepOutputView() GrepOutputModel* GrepOutputView::renewModel() { - GrepOutputModel* oldModel = model(); + if (model()) { + model()->deleteLater(); + } + GrepOutputModel* newModel = new GrepOutputModel(resultsTreeView); resultsTreeView->setModel(newModel); + connect(newModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), + this, SLOT(rowsRemoved())); connect(resultsTreeView, SIGNAL(activated(QModelIndex)), newModel, SLOT(activate(QModelIndex))); connect(newModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(expandRootElement(QModelIndex))); connect(newModel, SIGNAL(showErrorMessage(QString,int)), this, SLOT(showErrorMessage(QString))); - oldModel->deleteLater(); return newModel; } @@ -105,7 +112,7 @@ void GrepOutputView::setMessage(const QString& msg) void GrepOutputView::enableReplace(bool enable) { - m_apply->setEnabled(enable); + m_apply->setVisible(enable); } void GrepOutputView::showErrorMessage( const QString& errorMessage ) @@ -122,6 +129,7 @@ void GrepOutputView::showMessage( KDevelop::IStatus* , const QString& message ) void GrepOutputView::onApply() { + Q_ASSERT(model()->rowCount()); setEnabled(false); model()->doReplacements(); setEnabled(true); @@ -138,6 +146,10 @@ void GrepOutputView::expandRootElement(const QModelIndex& parent) { resultsTreeView->setExpanded(model()->index(0,0), true); } + + m_apply->setEnabled(true); + m_prev->setEnabled(true); + m_next->setEnabled(true); } void GrepOutputView::selectPreviousItem() @@ -160,4 +172,11 @@ void GrepOutputView::selectNextItem() resultsTreeView->setCurrentIndex(next_idx); model()->activate(next_idx); } -} \ No newline at end of file +} + +void GrepOutputView::rowsRemoved() +{ + m_apply->setEnabled(model()->rowCount()); + m_prev->setEnabled(model()->rowCount()); + m_next->setEnabled(model()->rowCount()); +} diff --git a/plugins/grepview/grepoutputview.h b/plugins/grepview/grepoutputview.h index 14cdd68..d4a7416 100644 --- a/plugins/grepview/grepoutputview.h +++ b/plugins/grepview/grepoutputview.h @@ -64,6 +64,8 @@ Q_SIGNALS: private: QAction* m_apply; + QAction* m_next; + QAction* m_prev; GrepViewPlugin *m_plugin; private slots: @@ -72,6 +74,7 @@ private slots: void onApply(); void showDialog(); void expandRootElement( const QModelIndex & parent ); + void rowsRemoved(); }; #endif // GREPOUTPUTVIEW_H Git commit 26538cbadb56610f3c4c5f0f1e1b6ea5900a1353 by Aleix Pol, on behalf of Milian Wolff. Committed on 01/12/2010 at 21:40. Pushed by apol into branch '1.1wreck'. make sure we don't try to apply / jump to prev/next item if we don't have any matches hide apply button when we only search for items M +2 -1 plugins/grepview/grepoutputmodel.cpp M +31 -12 plugins/grepview/grepoutputview.cpp M +3 -0 plugins/grepview/grepoutputview.h http://commits.kde.org/kdevplatform/26538cbadb56610f3c4c5f0f1e1b6ea5900a1353 |