[BUG]: Linux下,打印功能不可用,程序崩溃
Describe the bug 【Bug描述】
在Linux平台下运行QCefViewTest程序,右键选择打印,程序崩溃,报错信息:
[0915/161844.284269:ERROR:print_dialog_linux.cc(156)] Null interface in CreatePrintDialog; printing will fail.
[0915/161844.284334:ERROR:device_event_log_impl.cc(222)] [16:18:44.284] Printer: print_error_dialog.cc:61 所选打印机无法使用或未正确安装。请检查打印机,或尝试选择其他打印机。
[0915/161844.286439:FATAL:message_box_dialog.cc(231)] Check failed: !is_system_modal.
直接使用js的window.print(),或者开发者工具里调用window.print()均会导致程序崩溃。
另外,测试cefclient、cefsimple,NCW,OSR模式下均可以正常调用打印对话框,不会崩溃。
To Reproduce 【复现步骤】
- 调用打印功能
- 崩溃
Expected behavior 【正确的预期行为】
调用系统打印对话框
Screenshots 【截图】
...
Environment 【BUG产生的环境】
- OSR/NCW Mode: all
- OS & Version: Linux
- Qt Version: 5.15.2
- CEF Version: 113.3.5+g0b33855+chromium-113.0.5672.129
Additional context 【更多额外信息】
测试平台:UOS、Ubuntu 22.04.3 LTS
我也碰到这个问题,有初步的怀疑原因吗?
我也碰到这个问题,有初步的怀疑原因吗?
当时怀疑是没有实现打印功能
是没实现,实现这个接口就好了:/// /// Implement this interface to handle printing on Linux. Each browser will have /// only one print job in progress at a time. The methods of this class will be /// called on the browser process UI thread. /// /--cef(source=client)--/ class CefPrintHandler : public virtual CefBaseRefCounted {
是没实现,实现这个接口就好了:/// /// Implement this interface to handle printing on Linux. Each browser will have /// only one print job in progress at a time. The methods of this class will be /// called on the browser process UI thread. /// /--cef(source=client)--/ class CefPrintHandler : public virtual CefBaseRefCounted {
如果可以的话,欢迎提交PR
ubuntu 上测试没什么问题,是不是已经修复了。
PS: 如果想要内核的打印预览,可以加上参数。
config.addCommandLineSwitch("enable-print-preview");