fix: 修复默认程序设置失败的问题
指针初始化未置空,导致的判断出错 Log: 修复默认程序设置失败的问题 Influence: 默认程序设置 Task: https://pms.uniontech.com/task-view-235759.html Change-Id: Ieb4d7ad1a41e9200447cff7470541461e7129bfb
This commit is contained in:
		@ -219,7 +219,7 @@ std::vector<std::string> AppInfoManger::getAppList(std::string mimeType)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool AppInfoManger::getDefaultApp(std::string mimeType, std::string desktopId)
 | 
			
		||||
bool AppInfoManger::setDefaultApp(std::string mimeType, std::string desktopId)
 | 
			
		||||
{
 | 
			
		||||
    GDesktopAppInfo* gDesktopAppInfo = g_desktop_app_info_new(desktopId.c_str());
 | 
			
		||||
 | 
			
		||||
@ -229,7 +229,7 @@ bool AppInfoManger::getDefaultApp(std::string mimeType, std::string desktopId)
 | 
			
		||||
 | 
			
		||||
    GAppInfo* gAppInfo = G_APP_INFO(gDesktopAppInfo);
 | 
			
		||||
 | 
			
		||||
    GError* err;
 | 
			
		||||
    GError* err = nullptr;
 | 
			
		||||
    g_app_info_set_as_default_for_type(gAppInfo, mimeType.c_str(), &err);
 | 
			
		||||
 | 
			
		||||
    if (err != nullptr) {
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ public:
 | 
			
		||||
    static std::shared_ptr<AppInfoManger> loadByDesktopId(std::string desktopId);
 | 
			
		||||
    static std::string getDefaultApp(std::string mimeType, bool supportUri);
 | 
			
		||||
    static std::vector<std::string> getAppList(std::string mimeType);
 | 
			
		||||
    static bool getDefaultApp(std::string mimeType, std::string desktopId);
 | 
			
		||||
    static bool setDefaultApp(std::string mimeType, std::string desktopId);
 | 
			
		||||
    static std::vector<std::string>& getXdgDataDirs();
 | 
			
		||||
    static std::vector<std::string>& getXdgAppsDirs();
 | 
			
		||||
    static std::vector<std::shared_ptr<AppInfoManger>> getAll(std::map<std::string, std::vector<std::string>> skipDirs);
 | 
			
		||||
 | 
			
		||||
@ -291,7 +291,7 @@ bool MimeApp::setDefaultApp(const std::string &mimeType, const  std::string &des
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return  AppInfoManger::getDefaultApp(mimeType, desktopId);
 | 
			
		||||
    return  AppInfoManger::setDefaultApp(mimeType, desktopId);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MimeApp::DeleteApp(QStringList mimeTypes, const QString &desktopId)
 | 
			
		||||
@ -415,7 +415,7 @@ void MimeApp::SetDefaultApp(const QStringList &mimeTypes, const QString &desktop
 | 
			
		||||
        if (mime.toStdString().compare(AppinfoCommon::AppMimeTerminal) == 0) {
 | 
			
		||||
            bSuccess = TerminalInfo::getInstanceTerminal().setDefaultTerminal(desktopId.toStdString());
 | 
			
		||||
        } else {
 | 
			
		||||
            bSuccess = AppInfoManger::getDefaultApp(mime.toStdString(), desktopId.toStdString());
 | 
			
		||||
            bSuccess = AppInfoManger::setDefaultApp(mime.toStdString(), desktopId.toStdString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!bSuccess) {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user