From 3cd85eec0008677b947cc8928f8425af3d480d95 Mon Sep 17 00:00:00 2001 From: keke <243768648@qq.com> Date: Thu, 15 Sep 2022 17:28:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86=E4=BF=9D=E6=8C=81=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=B1=BB=E5=BA=94=E7=94=A8=E5=88=97=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=85=A8=E9=83=A8=E7=A7=BB=E9=99=A4=E5=90=8E?= =?UTF-8?q?=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appmanagerwidget.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/appmanagerwidget.cpp b/src/appmanagerwidget.cpp index 936f462..ab8bbb3 100644 --- a/src/appmanagerwidget.cpp +++ b/src/appmanagerwidget.cpp @@ -539,7 +539,11 @@ void AppManagerWidget::onAppInstalled(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 更改后,显示列表当前选中应用 - AppInfo currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + AppInfo currentAppInfo; + if (0 <= m_appListView->currentIndex().row() && + m_appListView->currentIndex().row() < m_showingInfoList.size()) { + currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + } showAppInfo(currentAppInfo); } // 更新应用个数标签 @@ -665,7 +669,11 @@ void AppManagerWidget::onAppUpdated(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 更改后,显示列表当前选中应用 - AppInfo currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + AppInfo currentAppInfo; + if (0 <= m_appListView->currentIndex().row() && + m_appListView->currentIndex().row() < m_showingInfoList.size()) { + currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + } showAppInfo(currentAppInfo); } // 更新应用个数标签 @@ -728,7 +736,11 @@ void AppManagerWidget::onAppUninstalled(const AM::AppInfo &appInfo) // 刷新右侧显示内容 if (appInfo.pkgName == m_showingAppInfo.pkgName) { // 删除后,显示列表当前选中应用 - AppInfo currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + AppInfo currentAppInfo; + if (0 <= m_appListView->currentIndex().row() && + m_appListView->currentIndex().row() < m_showingInfoList.size()) { + currentAppInfo = m_showingInfoList.at(m_appListView->currentIndex().row()); + } showAppInfo(currentAppInfo); } // 更新应用个数标签 @@ -805,6 +817,9 @@ void AppManagerWidget::setItemModelFromAppInfoList(const QList &appInfo if (!m_showingInfoList.isEmpty()) { m_appListView->setCurrentIndex(m_appListModel->index(0, 0)); showAppInfo(m_showingInfoList[0]); + } else { + // 此类别无应用,则显示空信息 + showAppInfo(AppInfo()); } } -- Gitee