Commit a437d39e authored by Carlo Vanini's avatar Carlo Vanini
Browse files

Connect to backend signals to catch cache reload.

When the cache is reloaded libqapt deletes Package objects and creates them
anew. This results in dangling pointers in muon models.

When "Preview Changes" is shown we have two models with lists of packages, and
both should be cleared and repopulated.

The cache reload can be triggered by pinning/unpinning (lock/unlock) a package.

REVIEW: 127107
BUG: 332530
parent 465ca5fc
......@@ -136,6 +136,8 @@ void MainWindow::initObject()
emit backendReady(m_backend);
connect(m_backend, SIGNAL(packageChanged()),
this, SLOT(setActionsEnabled()));
connect(m_backend, SIGNAL(cacheReloadFinished()),
this, SLOT(setActionsEnabled()));
// Set up GUI
loadSettings();
......
......@@ -240,6 +240,8 @@ void PackageWidget::setBackend(QApt::Backend *backend)
m_backend = backend;
connect(m_backend, SIGNAL(packageChanged()), m_detailsWidget, SLOT(refreshTabs()));
connect(m_backend, SIGNAL(packageChanged()), m_model, SLOT(externalDataChanged()));
connect(m_backend, SIGNAL(cacheReloadStarted()), this, SLOT(cacheReloadStarted()));
connect(m_backend, SIGNAL(cacheReloadFinished()), this, SLOT(cacheReloadFinished()));
m_detailsWidget->setBackend(backend);
m_proxyModel->setBackend(m_backend);
......@@ -252,18 +254,28 @@ void PackageWidget::setBackend(QApt::Backend *backend)
}
void PackageWidget::reload()
{
m_backend->reloadCache();
}
void PackageWidget::cacheReloadStarted()
{
m_detailsWidget->clear();
m_model->clear();
m_proxyModel->clear();
m_proxyModel->reset();
m_proxyModel->setSourceModel(0);
m_busyWidget->start();
m_backend->reloadCache();
}
void PackageWidget::cacheReloadFinished()
{
QApt::PackageList packageList = m_backend->availablePackages();
QFuture<QList<QApt::Package*> > future = QtConcurrent::run(sortPackages, packageList);
m_watcher->setFuture(future);
m_proxyModel->setSourceModel(m_model);
m_packageView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
startSearch();
}
void PackageWidget::packageActivated(const QModelIndex &index)
......
......@@ -106,6 +106,8 @@ private:
public Q_SLOTS:
void setBackend(QApt::Backend *backend);
void reload();
void cacheReloadStarted();
void cacheReloadFinished();
void setFocusSearchEdit();
void startSearch();
void invalidateFilter();
......
......@@ -73,6 +73,8 @@ void StatusWidget::setBackend(QApt::Backend *backend)
m_backend = backend;
connect(m_backend, SIGNAL(packageChanged()),
this, SLOT(updateStatus()));
connect(m_backend, SIGNAL(cacheReloadFinished()),
this, SLOT(updateStatus()));
connect(m_backend, SIGNAL(xapianUpdateStarted()),
this, SLOT(showXapianProgress()));
connect(m_backend, SIGNAL(xapianUpdateProgress(int)),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment