Can't build GUI-optional (CLI mode) app because of qode.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- cpp, javascript, node.js
Hướng nghiên cứu
Start with the supplied starter-repo reproduction and compare node dist --cli with qode dist --cli, including the version where the GUI branch is removed. Trace qode's event-loop initialization and determine how to defer it until NodeGUI is used; done means the CLI process exits after its work while the GUI path remains alive.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
I want to create an app that can work with gui by default but optionally allow to pass some cli flags to skip the GUI.
But qode injects stuff into node.js event loop, causing simple console.log(123); app to run forever (until I forcibly quit it with ctrl+c or process.exit() in the code).
Creating a "starter script", that will try to decide if I should run the app with node or qode (and replace static imports with dynamic imports of nodegui) is no perfect, because sometimes I want to do cli only background job, but sometimes I want to popup a window to let user decide about something.
Adding process.exit(0) at the end of my script isn't too perfect again, because I'd have to keep track of all started background tasks somehow, to be sure if that's the right moment to call process.exit();
Is there a way to rework qode that it will only start to inject event loop stuff on demand, when a first QT stuff is created?
This way node can close the app automatically when all the background stuff ends.
To Reproduce
Steps to reproduce the behavior:
- Use this code in the starter repo:
const action = process.argv[2];
if (action === "--cli") {
console.log("doing stuff via cli");
}
else {
(async () => {
const { QMainWindow, QLabel } = await import("@nodegui/nodegui")
const win = new QMainWindow();
win.setWindowTitle("Hello World");
const label = new QLabel();
label.setText("Do stuff via GUI");
win.setCentralWidget(label);
win.show();
(global as any).win = win;
})();
}
Run node dist --cli - this is how node is behaving - it will quit the app after console log
Run qode dist --cli - qode will keep app running forever, even if no nodegui stuff is ever used (you can even remove the else)
Expected behavior
With above code app should quit automatically with qode when run with --cli flag. It should not without the flag of course to let GUI live.
Screenshots
no screenshots
Desktop (please complete the following information):
- OS: Linux
- NodeGUI version: 0.58.0-rc2
- OS Version: Mint 21.1 Cinnamon
Additional context
It's all written in the top.
- Ngôn ngữ chính
- C++
- Star
- 9.2k
- Fork
- 315
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nodegui/nodegui
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Support QTransform Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Beginner question about Node-GUI Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
QIcon::fromTheme for X11/Wayland Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Is this project dead? Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Tất cả issue của nodegui/nodegui
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
bug-unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
tenstorrent/tt-metal#57220 ·
-
Needs: Author Feedback Needs: Repro
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
react/react-native#58621 · 1 bình luận ·
-
为"信用收支>高级设置"中的"子串即可"添加注解 Đang mởenhancement module: others
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
MaaAssistantArknights/MaaAssistantArknights#18296 · 2 bình luận ·