Browse Source

Fix crash when exiting qbt with search plugin dialog open

Avoid emitting signal in destructor
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
24a69a9fe7
  1. 3
      src/base/searchengine.cpp
  2. 2
      src/base/searchengine.h
  3. 2
      src/gui/search/pluginselectdlg.cpp
  4. 3
      src/gui/search/pluginselectdlg.h
  5. 21
      src/gui/search/searchwidget.cpp

3
src/base/searchengine.cpp

@ -141,6 +141,8 @@ void SearchEngine::enablePlugin(const QString &name, bool enabled)
else if (!disabledPlugins.contains(name)) else if (!disabledPlugins.contains(name))
disabledPlugins.append(name); disabledPlugins.append(name);
pref->setSearchEngDisabled(disabledPlugins); pref->setSearchEngDisabled(disabledPlugins);
emit pluginEnabled(name, enabled);
} }
} }
@ -239,6 +241,7 @@ bool SearchEngine::uninstallPlugin(const QString &name)
// Remove it from supported engines // Remove it from supported engines
delete m_plugins.take(name); delete m_plugins.take(name);
emit pluginUninstalled(name);
return true; return true;
} }

2
src/base/searchengine.h

@ -103,8 +103,10 @@ signals:
void searchFailed(); void searchFailed();
void newSearchResults(const QList<SearchResult> &results); void newSearchResults(const QList<SearchResult> &results);
void pluginEnabled(const QString &name, bool enabled);
void pluginInstalled(const QString &name); void pluginInstalled(const QString &name);
void pluginInstallationFailed(const QString &name, const QString &reason); void pluginInstallationFailed(const QString &name, const QString &reason);
void pluginUninstalled(const QString &name);
void pluginUpdated(const QString &name); void pluginUpdated(const QString &name);
void pluginUpdateFailed(const QString &name, const QString &reason); void pluginUpdateFailed(const QString &name, const QString &reason);

2
src/gui/search/pluginselectdlg.cpp

@ -103,7 +103,6 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
PluginSelectDlg::~PluginSelectDlg() PluginSelectDlg::~PluginSelectDlg()
{ {
emit pluginsChanged();
delete m_ui; delete m_ui;
} }
@ -461,7 +460,6 @@ void PluginSelectDlg::pluginUpdated(const QString &name)
item->setText(PLUGIN_VERSION, version); item->setText(PLUGIN_VERSION, version);
m_updatedPlugins.append(name); m_updatedPlugins.append(name);
finishPluginUpdate(); finishPluginUpdate();
} }
void PluginSelectDlg::pluginUpdateFailed(const QString &name, const QString &reason) void PluginSelectDlg::pluginUpdateFailed(const QString &name, const QString &reason)

3
src/gui/search/pluginselectdlg.h

@ -56,9 +56,6 @@ public:
QList<QTreeWidgetItem*> findItemsWithUrl(QString url); QList<QTreeWidgetItem*> findItemsWithUrl(QString url);
QTreeWidgetItem* findItemWithID(QString id); QTreeWidgetItem* findItemWithID(QString id);
signals:
void pluginsChanged();
protected: protected:
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);

21
src/gui/search/searchwidget.cpp

@ -121,11 +121,19 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
connect(m_searchEngine, &SearchEngine::searchFailed, this, &SearchWidget::searchFailed); connect(m_searchEngine, &SearchEngine::searchFailed, this, &SearchWidget::searchFailed);
connect(m_searchEngine, &SearchEngine::torrentFileDownloaded, this, &SearchWidget::addTorrentToSession); connect(m_searchEngine, &SearchEngine::torrentFileDownloaded, this, &SearchWidget::addTorrentToSession);
// Fill in category combobox const auto onPluginChanged = [this]()
fillCatCombobox(); {
fillPluginComboBox(); fillCatCombobox();
fillPluginComboBox();
selectActivePage();
};
connect(m_searchEngine, &SearchEngine::pluginInstalled, this, onPluginChanged);
connect(m_searchEngine, &SearchEngine::pluginUninstalled, this, onPluginChanged);
connect(m_searchEngine, &SearchEngine::pluginUpdated, this, onPluginChanged);
connect(m_searchEngine, &SearchEngine::pluginEnabled, this, onPluginChanged);
selectActivePage(); // Fill in category combobox
onPluginChanged();
connect(m_ui->m_searchPattern, &LineEdit::returnPressed, m_ui->searchButton, &QPushButton::click); connect(m_ui->m_searchPattern, &LineEdit::returnPressed, m_ui->searchButton, &QPushButton::click);
connect(m_ui->m_searchPattern, &LineEdit::textEdited, this, &SearchWidget::searchTextEdited); connect(m_ui->m_searchPattern, &LineEdit::textEdited, this, &SearchWidget::searchTextEdited);
@ -248,10 +256,7 @@ void SearchWidget::addTorrentToSession(const QString &source)
void SearchWidget::on_pluginsButton_clicked() void SearchWidget::on_pluginsButton_clicked()
{ {
PluginSelectDlg *dlg = new PluginSelectDlg(m_searchEngine, this); new PluginSelectDlg(m_searchEngine, this);
connect(dlg, &PluginSelectDlg::pluginsChanged, this, &SearchWidget::fillCatCombobox);
connect(dlg, &PluginSelectDlg::pluginsChanged, this, &SearchWidget::fillPluginComboBox);
connect(dlg, &PluginSelectDlg::pluginsChanged, this, &SearchWidget::selectActivePage);
} }
void SearchWidget::searchTextEdited(QString) void SearchWidget::searchTextEdited(QString)

Loading…
Cancel
Save