CefView / QCefView

A Qt Widget encapsulated CEF view based on QWidget
https://cefview.github.io/QCefView/
GNU Lesser General Public License v2.1
546 stars 144 forks source link

关闭是否支持 要怎么处理有好的思路吗? #68

Closed w08 closed 2 years ago

w08 commented 2 years ago

程序退出如果有窗口没关闭,则进程残留

tishion commented 2 years ago

程序退出为什么出现窗口没有关闭?

airheadork commented 2 years ago

我也发现这个现象.在QMainWindow里嵌入QCefView, 通过右上角的关闭按钮去关闭程序, 那么程序能正常退出. 如果通过qApp->quit()去退出应用, 那么有进程残留.

tishion commented 2 years ago

你们遇到问题能否贴个代码片段出来?在什么时候调用qApp->quit()?

airheadork commented 2 years ago

可以在界面上加个button, 点击button退出应用. connect(ui.btn_quit, &QPushButton::clicked, [=]() { qApp->quit(); }); alt 界面 alt 代码

w08 commented 2 years ago

我注释了 setParent(nullptr); 来避免 渲染进程偶发无法退出,且无法退出时还后台CPU高的问题。 void QCefViewPrivate::closeBrowser() { if (!pCefBrowser_) return;

// remove the browser from parent tree, or CEF will send close // event to the top level window, this will cause the application // to exit the event loop, this is not what we expected to happen //避免关闭后进程不退。 //qBrowserWindow_->setParent(nullptr);

不知道会不会有影响

tishion commented 2 years ago

你们反馈的问题,我这边都无法复现,可以提供一下调用quit之后的主线程堆栈么?截个图,看一下主线程是在做什么事情而没有退出?

airheadork commented 2 years ago

` [外部代码]
win32u.dll![下面的框架可能不正确和/或缺失,没有为 win32u.dll 加载符号] 未知 Qt5Cored.dll!QEventDispatcherWin32::processEvents(QFlags flags) 行 573 C++ qwindowsd.dll!QWindowsGuiEventDispatcher::processEvents(QFlags flags) 行 73 C++ Qt5Cored.dll!QCoreApplication::processEvents(QFlags flags) 行 1285 C++ [外部代码]
Qt5Cored.dll!doActivate<0>(QObject sender, int signal_index, void argv) 行 3898 C++ Qt5Cored.dll!QMetaObject::activate(QObject sender, const QMetaObject m, int local_signal_index, void * argv) 行 3946 C++ Qt5Cored.dll!QCoreApplication::aboutToQuit(QCoreApplication::QPrivateSignal _t1) 行 254 C++ Qt5Cored.dll!QCoreApplicationPrivate::execCleanup() 行 1392 C++ Qt5Cored.dll!QCoreApplication::exec() 行 1377 C++ Qt5Guid.dll!QGuiApplication::exec() 行 1868 C++ Qt5Widgetsd.dll!QApplication::exec() 行 2825 C++

QCefViewTest.exe!main(int argc, char argv) 行 36 C++ QCefViewTest.exe!WinMain(HINSTANCE * formal, HINSTANCE * formal, char * formal, int formal) 行 97 C++ [外部代码]

`

tishion commented 2 years ago

Fixed: Commit: https://github.com/CefView/QCefView/commit/7c93bbb444138bbf54ca299f4198baafe9ebc6a4