[Exchange and share] 全局搜索网页结果会打开两个标签页的解决方案
Tofloor
poster avatar
deepin-superuser
deepin
2024-02-29 16:28
Author

原因分析:

dde-grand-search/src/grand-search/utils/utils.cpp



bool Utils::launchAppByGio(const QString &desktopFile, const QStringList &filePaths)
{
    // 使用gio接口启动应用
    std::string stdDesktopFilePath = desktopFile.toStdString();
    const char *cDesktopPath = stdDesktopFilePath.data();

    GDesktopAppInfo *appInfo = g_desktop_app_info_new_from_filename(cDesktopPath);
    if (!appInfo) {
        //qDebug() << "Failed to open desktop file with gio: g_desktop_app_info_new_from_filename returns NULL. Check PATH maybe?";
        return false;
    }

    GList *g_files = nullptr;
    foreach (const QString &filePath, filePaths) {
        std::string stdFilePath = filePath.toStdString();
        const char *cFilePath = stdFilePath.data();
        GFile *f = g_file_new_for_uri(cFilePath);
        g_files = g_list_append(g_files, f);
    }

    GError *gError = nullptr;
    gboolean ok = g_app_info_launch(reinterpret_cast(appInfo), g_files, nullptr, &gError);

    if (gError) {
        qWarning() << "Error when trying to open desktop file with gio:" << gError->message;
        g_error_free(gError);
    }

    if (!ok) {
        qWarning() << "Failed to open desktop file with gio: g_app_info_launch returns false";
    }
    g_object_unref(appInfo);
    g_list_free(g_files);

    // 问题出在这里,上边已经使用 g_app_info_launch 启动过一次浏览器了,这里又通过 gio 启动了一次,
    // 所以可以注释掉下边的代码或者复制到上边的 if (!ok) {} 中
    /*
    for (auto filePath : filePaths) {
        if (!filePath.isEmpty())
            QProcess::startDetached("gio", QStringList() << "open" << filePath);
    }
    */

    return ok;
}

附编译后文件

dde-grand-search_5.4.5+kt286_amd64.zip

Reply Favorite View the author
All Replies
buyike
deepin
2024-02-29 16:33
#1

yeah666


输入360搜不到,输入极速就可以搜到了。
image.png

Reply View the author
deepin-superuser
deepin
2024-02-29 16:46
#2
buyike

yeah666


输入360搜不到,输入极速就可以搜到了。
image.png

这是因为你文件名字里有360的太多了

image.png

Reply View the author
liwl
deepin
2024-02-29 16:49
#3

like

这是个bug,issue直接提交官方?

正式版本应该可以修复

Reply View the author
deepin-superuser
deepin
2024-02-29 16:57
#4
liwl

like

这是个bug,issue直接提交官方?

正式版本应该可以修复

PR 已提交 然后就是漫长的等待期

Reply View the author
buyike
deepin
2024-02-29 17:42
#5
deepin-superuser

这是因为你文件名字里有360的太多了

image.png

你用的啥壁纸呀,虚化后色彩很漂亮呀。

Reply View the author
阿尼樱奈奈
Moderator
2024-02-29 17:48
#6
buyike

你用的啥壁纸呀,虚化后色彩很漂亮呀。

这张吗:
Colorful-Abstraction02.jpg

Reply View the author
buyike
deepin
2024-02-29 17:56
#7
阿尼樱奈奈

这张吗:
Colorful-Abstraction02.jpg

是的,这个色彩很漂亮。

Reply View the author
星语我梦
deepin
2024-03-12 23:26
#8
buyike

yeah666


输入360搜不到,输入极速就可以搜到了。
image.png

这个字体好看,请问是啥字体呢?

Reply View the author