修复显示右键菜单可能导致崩溃问题

This commit is contained in:
hewenfei 2023-04-18 16:43:36 +08:00 committed by He Sir
parent 24ca01368f
commit c8e515fd74
3 changed files with 5 additions and 6 deletions

View File

@ -226,7 +226,7 @@ void MenuManager::showMenu(const DataEntity &entity, const QPoint &point)
showMenu(MenuProvider::DataType, QVariant::fromValue(entity), point);
}
void MenuManager::showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point)
void MenuManager::showMenu(const MenuProvider::RequestType &type, QVariant data, const QPoint &point)
{
QMenu menu;

View File

@ -38,7 +38,7 @@ public:
void registerMenuProvider(MenuProvider *provider);
Q_INVOKABLE void showMenu(const QString &appid, const QPoint &point = QPoint());
void showMenu(const DataEntity &entity, const QPoint &point = QPoint());
void showMenu(const MenuProvider::RequestType &type, const QVariant &data, const QPoint &point = QPoint());
void showMenu(const MenuProvider::RequestType &type, QVariant data, const QPoint &point = QPoint());
private:
MenuManager();

View File

@ -189,11 +189,10 @@ void AppModel::insertData(QVector<DataEntity> &data, int index)
void AppModel::openMenu(const int &index)
{
if (index < 0 || index >= m_apps.size()) {
return;
QModelIndex modelIndex = createIndex(index, 0, nullptr);
if (modelIndex.isValid()) {
MenuManager::instance()->showMenu(modelIndex.data(DataEntity::Id).toString());
}
MenuManager::instance()->showMenu(m_apps.at(index));
}
void AppModel::renameFolder(const QString &index, const QString &folderName)