CefView / QCefView

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

[BUG]: devtools窗口一闪而过 #247

Closed mensong closed 1 year ago

mensong commented 1 year ago

Describe the bug 【Bug描述】

... 之前showdevtools可以展示的,获取新的代码后,发现devtools窗口一闪而过就不见了。 进过排查,发现是新增的以下代码导致的:

void QCefViewPrivate::onCefBrowserCreated(CefRefPtr browser, QWindow* window) { // capture the browser pCefBrowser_ = browser;

// #if defined(CEF_USEOSR) if (isOSRModeEnabled) { // notify the visibility and size pCefBrowser_->GetHost()->WasHidden(!qptr->isVisible()); pCefBrowser->GetHost()->WasResized(); connect(this, SIGNAL(updateOsrFrame()), q_ptr, SLOT(update()));

// monitor the screenChanged signal from the top-level window
disconnect(this, SLOT(onViewScreenChanged(QScreen*)));
if (q_ptr->window()->windowHandle()) {
  connect(q_ptr->window()->windowHandle(),    //
          SIGNAL(screenChanged(QScreen*)),    //
          this,                               //
          SLOT(onViewScreenChanged(QScreen*)) //
  );
}

} else { // #else // create QWidget from cef browser widow, this will re-parent the CEF browser window QWidget* browserWidget = QWidget::createWindowContainer( window, q_ptr, Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus); Q_ASSERT_X(browserWidget, "QCefViewPrivateNCW::createBrowser", "Failed to create QWidget from cef browser window"); if (!browserWidget) { qWarning("Failed to create QWidget from cef browser window"); browser->GetHost()->CloseBrowser(true); return; }

// capture the resource
ncw.qBrowserWindow_ = window;
ncw.qBrowserWidget_ = browserWidget;

// monitor the focus changed event globally
connect(qApp, &QApplication::focusChanged, this, &QCefViewPrivate::onAppFocusChanged);

// initialize the layout and add browser widget to the layout
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(ncw.qBrowserWidget_);
q_ptr->setLayout(layout);

// update mask
UpdateCefWindowMask(ncw.qBrowserWindow_, q_ptr->mask());

} // #endif

// emit signal q_ptr->browserCreated(q_ptr); }

虽然知道哪些代码导致的,但是不知道怎么改,麻烦看一下,谢谢。

tishion commented 1 year ago

拉一下最新代码看看,devtools是没有问题的。

mensong commented 1 year ago

测试OK了