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

Inverse search command not executed in development build #988

Closed
hpfmn opened this issue Feb 27, 2024 · 4 comments
Closed

Inverse search command not executed in development build #988

hpfmn opened this issue Feb 27, 2024 · 4 comments

Comments

@hpfmn
Copy link

hpfmn commented Feb 27, 2024

Hi,

I did a build of the development branch on macOS. With the current release my setting for inverse search does work. But with this branch it seems it doesn't get execute (I have a little bash script that stores the parameters in a file - but nothing is stored)

Is there anything changed regarding inverse search in the current development branch?

Best regards,
Johannes

@ahrm
Copy link
Owner

ahrm commented Feb 28, 2024

Inverse search should still work. Which program are you using for inverse search and what is your settings for that?

@ismasou
Copy link

ismasou commented Feb 28, 2024

For me too it didn't work, I thought it might be just my Qt version. It seems that in Qt6 the QProcess::startDetached needs separate arguments for the command and its arguments.
I use neovim, and I was able to make it work by changing the AUR patch to include this change to the startDetached.

diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
index 20f61e3..b33480b 100644
--- a/pdf_viewer/main_widget.cpp
+++ b/pdf_viewer/main_widget.cpp
@@ -4651,7 +4651,14 @@ std::wstring MainWidget::synctex_under_pos(WindowPos position) {
                 QString command = QString::fromStdWString(inverse_search_command).arg(file_name, line_string.c_str(), column_string.c_str());
 #endif
                 res = QString("%1 %2 %3").arg(new_path, QString::number(line), QString::number(column)).toStdWString();
-                QProcess::startDetached(command);
+                QString arg = QString("-c VimtexInverseSearch %1 '%2'").arg(line_string.c_str(), file_name);
+                QStringList args = {"--headless", arg};
+
+                QProcess::startDetached("/usr/bin/nvim", args);
             }
             else {
                 show_error_message(L"inverse_search_command is not set in prefs_user.config");
diff --git a/pdf_viewer_build_config.pro b/pdf_viewer_build_config.pro
index 83d286d..8a027b0 100644
--- a/pdf_viewer_build_config.pro
+++ b/pdf_viewer_build_config.pro
@@ -158,7 +158,8 @@ unix:!mac:!android {
     QMAKE_CXXFLAGS += -std=c++17
 
     CONFIG(linux_app_image){
-        LIBS += -ldl -Lmupdf/build/release -lmupdf -lmupdf-third -lmupdf-threads -lharfbuzz -lz
+        DEFINES += LINUX_STANDARD_PATHS
+        LIBS += -ldl -lmupdf -lz
     } else {
         DEFINES += NON_PORTABLE
         DEFINES += LINUX_STANDARD_PATHS

@ahrm Thank you for the very good software. I couldn't debug why sending the command with its arguments to startDetached doesn't work anymore in Qt6.
Let me know if you want me to create a PR with a proper fix for user defined inverse search, I guess now one needs to separate the command from its arguments before calling startDetached.

@jinjiaodawang
Copy link
Contributor

Can confirm the issue; and the issue happen might because the method QProcess::startDetached(const QString &command) is removed in Qt6.
Please refer to https://doc.qt.io/qt-5/qprocess-obsolete.html#startDetached-2

ahrm added a commit that referenced this issue Feb 28, 2024
fix #988, run inverse search command as separated command and args
@ahrm
Copy link
Owner

ahrm commented Feb 28, 2024

Should be fixed in ed77c64.

@ahrm ahrm closed this as completed Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants