Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unset LD_LIBRARY_PATH before openUrl #1555

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/auto-login-service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void AutoLoginService::startAutoLogin(const QString& next_url)
? account.getAbsoluteUrl(next_url)
: next_url;
if (!account.isValid() || !account.isAtLeastVersion(4, 2, 0)) {
QDesktopServices::openUrl(absolute_url);
openUrl(absolute_url);
return;
}

Expand Down Expand Up @@ -59,7 +59,7 @@ void AutoLoginService::onGetLoginTokenSuccess(const QString& token)
params.insert("next", req->nextUrl());
url = includeQueryParams(url, params);

QDesktopServices::openUrl(url);
openUrl(url);
req->deleteLater();
}

Expand All @@ -69,6 +69,6 @@ void AutoLoginService::onGetLoginTokenFailed(const ApiError& error)
qWarning("get login token failed: %s\n", error.toString().toUtf8().data());
// server doesn't support client directly login, or other errors happened.
// We open the server url directly in this case;
QDesktopServices::openUrl(req->account().getAbsoluteUrl(req->nextUrl()));
openUrl(req->account().getAbsoluteUrl(req->nextUrl()));
req->deleteLater();
}
2 changes: 1 addition & 1 deletion src/filebrowser/file-browser-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ void FileBrowserDialog::onOpenLocalCacheFolder()
seafApplet->warningBox(tr("Unable to create cache folder"), this);
return;
}
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(folder)))
if (!openUrl(QUrl::fromLocalFile(folder)))
seafApplet->warningBox(tr("Unable to open cache folder"), this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/init-vdrive-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void InitVirtualDriveDialog::onDownloadRepoFailure(const ApiError& error)

void InitVirtualDriveDialog::openVirtualDisk()
{
QDesktopServices::openUrl(QUrl::fromLocalFile(default_repo_path_));
openUrl(QUrl::fromLocalFile(default_repo_path_));
accept();
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/login-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void LoginDialog::clientSSOLinkSuccess(const QString& link)
QString sso_link(link);

qInfo() << "open sso link in browser:" << sso_link;
QDesktopServices::openUrl(QUrl(sso_link));
openUrl(QUrl(sso_link));

QRegularExpression re("/client-sso/([^/]+)");
QRegularExpressionMatch match = re.match(sso_link);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/repo-tree-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void RepoTreeView::showRepoDetail()
void RepoTreeView::openLocalFolder()
{
LocalRepo repo = qvariant_cast<LocalRepo>(open_local_folder_action_->data());
QDesktopServices::openUrl(QUrl::fromLocalFile(repo.worktree));
openUrl(QUrl::fromLocalFile(repo.worktree));
}

void RepoTreeView::toggleRepoAutoSync()
Expand Down Expand Up @@ -557,7 +557,7 @@ void RepoTreeView::onItemDoubleClicked(const QModelIndex& index)
const LocalRepo& local_repo = it->localRepo();
if (local_repo.isValid()) {
// open local folder for downloaded repo
QDesktopServices::openUrl(QUrl::fromLocalFile(local_repo.worktree));
openUrl(QUrl::fromLocalFile(local_repo.worktree));
} else {
// open seahub repo page for not downloaded repo
FileBrowserManager::getInstance()->openOrActivateDialog(
Expand All @@ -573,7 +573,7 @@ void RepoTreeView::viewRepoOnWeb()
if (account.isValid()) {
// we adopt a new format of cloud view url from server version 4.2.0
if (!account.isAtLeastVersion(4, 2, 0)) {
QDesktopServices::openUrl(account.getAbsoluteUrl("repo/" + selected_repo_.id));
openUrl(account.getAbsoluteUrl("repo/" + selected_repo_.id));
} else {
AutoLoginService::instance()->startAutoLogin("/library/" + selected_repo_.id + "/" + selected_repo_.name + "/");
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/starred-files-list-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void StarredFilesListView::viewFileOnWeb()
strurl = "lib/" + file.repo_id + "/file" + file.path;
}
QUrl url = account.getAbsoluteUrl(strurl);
QDesktopServices::openUrl(url);
openUrl(url);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/sync-errors-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void SyncErrorsTableView::onItemDoubleClicked(const QModelIndex& index)
LocalRepo repo;
seafApplet->rpcClient()->getLocalRepo(error.repo_id, &repo);
if (repo.isValid()) {
QDesktopServices::openUrl(QUrl::fromLocalFile(repo.worktree));
openUrl(QUrl::fromLocalFile(repo.worktree));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ui/tray-icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,12 @@ void SeafileTrayIcon::openHelp()
} else {
url = "https://help.seafile.com/syncing_client/install_sync/";
}
QDesktopServices::openUrl(QUrl(url));
openUrl(QUrl(url));
}

void SeafileTrayIcon::openSeafileFolder()
{
QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(seafApplet->configurator()->seafileDir()).path()));
openUrl(QUrl::fromLocalFile(QFileInfo(seafApplet->configurator()->seafileDir()).path()));
}

void SeafileTrayIcon::shellExtFix()
Expand Down Expand Up @@ -565,7 +565,7 @@ void SeafileTrayIcon::shellExtFix()
void SeafileTrayIcon::openLogDirectory()
{
QString log_path = QDir(seafApplet->configurator()->ccnetDir()).absoluteFilePath("logs");
QDesktopServices::openUrl(QUrl::fromLocalFile(log_path));
openUrl(QUrl::fromLocalFile(log_path));
}

void SeafileTrayIcon::uploadLogDirectory()
Expand Down
19 changes: 17 additions & 2 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ QString defaultDownloadDir() {
bool openInNativeExtension(const QString &path) {
#if defined(Q_OS_WIN32)
//call ShellExecute internally
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
return openUrl(QUrl::fromLocalFile(path));
#elif defined(Q_OS_MAC)
// mac's open program, it will fork to open the file in a subprocess
// so we will wait for it to check whether it succeeds or not
Expand Down Expand Up @@ -177,7 +177,7 @@ bool showInGraphicalShell(const QString& path) {
QProcess::execute("/usr/bin/osascript", scriptArgs);
return true;
#else
return QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(path).absolutePath()));
return openUrl(QUrl::fromLocalFile(QFileInfo(path).absolutePath()));
#endif
}

Expand Down Expand Up @@ -838,3 +838,18 @@ QString trimNULL(QString& s) {
}
return s;
}

bool openUrl(QUrl url) {
#ifdef Q_OS_LINUX
// On linux openUrl will open the default browser via xgd-open, at this time LD_LIBRARY_PATH may affect xdg-open.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On linux openUrl will open the default browser via xgd-open. If the client is packaged as AppImage format, LD_LIBRARY_PATH is set to package location and may affect xdg-open.

// We should unset this environment variable before openUrl, and reset it after openUrl.
QByteArray ldPath = qgetenv("LD_LIBRARY_PATH");
qunsetenv("LD_LIBRARY_PATH");
#endif
QDesktopServices::openUrl(url);
#ifdef Q_OS_LINUX
if (!ldPath.isEmpty()) {
qputenv("LD_LIBRARY_PATH", ldPath);
}
#endif
}
2 changes: 2 additions & 0 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ const QRect getScreenSize(int index);

QString trimNULL(QString& s);

bool openUrl(QUrl url);

#endif