fix(frontend): Process crushed when openning apps.

Description: 修复打开应用时全局搜索崩溃的问题

Log: 修复打开应用时全局搜索崩溃的问题
Bug: http://172.17.66.192/biz/bug-view-33144.html
This commit is contained in:
zhangjiaping 2021-01-14 09:52:34 +08:00
parent b044ca189f
commit 4e0ee32008
4 changed files with 25 additions and 40 deletions

View File

@ -158,6 +158,15 @@ int ContentWidget::currentPage() {
*/ */
void ContentWidget::refreshSearchList(const QVector<int>& types, const QVector<QStringList>& lists, const QString& keyword) { void ContentWidget::refreshSearchList(const QVector<int>& types, const QVector<QStringList>& lists, const QString& keyword) {
if (!m_listLyt->isEmpty()) { if (!m_listLyt->isEmpty()) {
if (m_fileListView) {
m_fileListView->clear();
}
if (m_dirListView) {
m_dirListView->clear();
}
if (m_contentListView) {
m_contentListView->clear();
}
clearLayout(m_listLyt); clearLayout(m_listLyt);
m_resultList->setFixedHeight(0); m_resultList->setFixedHeight(0);
} }
@ -396,15 +405,6 @@ QString ContentWidget::getTitleName(const int& type) {
* @param layout * @param layout
*/ */
void ContentWidget::clearLayout(QLayout * layout) { void ContentWidget::clearLayout(QLayout * layout) {
if (m_fileListView) {
m_fileListView->clear();
}
if (m_dirListView) {
m_dirListView->clear();
}
if (m_contentListView) {
m_contentListView->clear();
}
m_contentList.clear(); m_contentList.clear();
if (! layout) return; if (! layout) return;
QLayoutItem * child; QLayoutItem * child;

View File

@ -58,7 +58,6 @@ bool ConfigFile::writeRecently(QString message){
recently.insert(0,message); recently.insert(0,message);
m_qSettings->beginGroup("Recently"); m_qSettings->beginGroup("Recently");
qWarning()<<m_qSettings->value("Recently").toStringList().length();
if (m_qSettings->value("Recently").toStringList().length() >= 20) { if (m_qSettings->value("Recently").toStringList().length() >= 20) {
m_qSettings->setValue("Recently",QStringList(recently.mid(0, 20))); m_qSettings->setValue("Recently",QStringList(recently.mid(0, 20)));
} else { } else {

View File

@ -34,20 +34,14 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
case SearchListView::ResType::Content: case SearchListView::ResType::Content:
case SearchListView::ResType::Dir: case SearchListView::ResType::Dir:
case SearchListView::ResType::File: { case SearchListView::ResType::File: {
QProcess * process = new QProcess; QProcess process;
process->start(QString("xdg-open %1").arg(path)); process.start(QString("xdg-open %1").arg(path));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
break; break;
} }
case SearchListView::ResType::Setting: { case SearchListView::ResType::Setting: {
//打开控制面板对应页面 //打开控制面板对应页面
QProcess * process = new QProcess; QProcess process;
process->start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower())); process.start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
break; break;
} }
default: default:

View File

@ -251,21 +251,15 @@ bool SearchDetailView::openAction(const int& type, const QString& path) {
case SearchListView::ResType::Content: case SearchListView::ResType::Content:
case SearchListView::ResType::Dir: case SearchListView::ResType::Dir:
case SearchListView::ResType::File: { case SearchListView::ResType::File: {
QProcess * process = new QProcess; QProcess process;
process->start(QString("xdg-open %1").arg(path)); process.start(QString("xdg-open %1").arg(path));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
return true; return true;
break; break;
} }
case SearchListView::ResType::Setting: { case SearchListView::ResType::Setting: {
//打开控制面板对应页面 //打开控制面板对应页面
QProcess * process = new QProcess; QProcess process;
process->start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower())); process.start(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
return true; return true;
break; break;
} }
@ -283,7 +277,9 @@ bool SearchDetailView::openAction(const int& type, const QString& path) {
bool SearchDetailView::writeConfigFile(const QString& path) { bool SearchDetailView::writeConfigFile(const QString& path) {
if (ConfigFile::writeConfig(path)) { if (ConfigFile::writeConfig(path)) {
Q_EMIT this->configFileChanged(); Q_EMIT this->configFileChanged();
return true;
} }
return false;
} }
/** /**
@ -299,11 +295,8 @@ bool SearchDetailView::addDesktopShortcut(const QString& path) {
bool ret = file.copy(QString(dirpath+"/"+desktopfn)); bool ret = file.copy(QString(dirpath+"/"+desktopfn));
if(ret) if(ret)
{ {
QProcess * process = new QProcess; QProcess process;
process->start(QString("chmod a+x %1").arg(newName)); process.start(QString("chmod a+x %1").arg(newName));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
return true; return true;
} }
return false; return false;
@ -328,6 +321,7 @@ bool SearchDetailView::addPanelShortcut(const QString& path) {
qDebug()<<"qDebug: Add shortcut to panel successed!"; qDebug()<<"qDebug: Add shortcut to panel successed!";
return true; return true;
} }
return false;
} }
/** /**
@ -335,11 +329,8 @@ bool SearchDetailView::addPanelShortcut(const QString& path) {
* @return * @return
*/ */
bool SearchDetailView::openPathAction(const QString& path) { bool SearchDetailView::openPathAction(const QString& path) {
QProcess * process = new QProcess; QProcess process;
process->start(QString("xdg-open %1").arg(path.left(path.lastIndexOf("/")))); process.start(QString("xdg-open %1").arg(path.left(path.lastIndexOf("/"))));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
return true; return true;
} }
@ -350,4 +341,5 @@ bool SearchDetailView::openPathAction(const QString& path) {
bool SearchDetailView::copyPathAction(const QString& path) { bool SearchDetailView::copyPathAction(const QString& path) {
QClipboard * clipboard = QApplication::clipboard(); //获取系统剪贴板指针 QClipboard * clipboard = QApplication::clipboard(); //获取系统剪贴板指针
clipboard->setText(path); clipboard->setText(path);
return true;
} }