Fix webview initialization on GCC.

This commit is contained in:
John Preston 2022-04-08 18:35:55 +04:00
parent 8721b7a689
commit d15ff46eb4
2 changed files with 15 additions and 15 deletions

View File

@ -491,28 +491,30 @@ bool Panel::showWebview(
}
bool Panel::createWebview() {
auto container = base::make_unique_q<RpWidget>(_widget.get());
auto outer = base::make_unique_q<RpWidget>(_widget.get());
const auto container = outer.get();
_widget->showInner(std::move(outer));
_webviewBottom = std::make_unique<RpWidget>(_widget.get());
const auto bottom = _webviewBottom.get();
bottom->show();
bottom->heightValue(
) | rpl::start_with_next([=, raw = container.get()](int height) {
) | rpl::start_with_next([=](int height) {
const auto inner = _widget->innerGeometry();
bottom->move(inner.x(), inner.y() + inner.height() - height);
raw->resize(inner.width(), inner.height() - height);
container->resize(inner.width(), inner.height() - height);
bottom->resizeToWidth(inner.width());
}, bottom->lifetime());
container->show();
_webview = std::make_unique<WebviewWithLifetime>(
container.get(),
container,
Webview::WindowConfig{
.userDataPath = _delegate->panelWebviewDataPath(),
});
const auto raw = &_webview->window;
QObject::connect(container.get(), &QObject::destroyed, [=] {
QObject::connect(container, &QObject::destroyed, [=] {
if (_webview && &_webview->window == raw) {
_webview = nullptr;
if (_webviewProgress) {
@ -563,8 +565,6 @@ postEvent: function(eventType, eventData) {
}
};)");
_widget->showInner(std::move(container));
setupProgressGeometry();
return true;

View File

@ -496,32 +496,34 @@ bool Panel::showWebview(
}
bool Panel::createWebview() {
auto container = base::make_unique_q<RpWidget>(_widget.get());
_webviewParent = container.get();
auto outer = base::make_unique_q<RpWidget>(_widget.get());
const auto container = outer.get();
_widget->showInner(std::move(outer));
_webviewParent = container;
_webviewBottom = std::make_unique<RpWidget>(_widget.get());
const auto bottom = _webviewBottom.get();
bottom->show();
bottom->heightValue(
) | rpl::start_with_next([=, raw = container.get()](int height) {
) | rpl::start_with_next([=](int height) {
const auto inner = _widget->innerGeometry();
if (_mainButton && !_mainButton->isHidden()) {
height = _mainButton->height();
}
bottom->move(inner.x(), inner.y() + inner.height() - height);
raw->resize(inner.width(), inner.height() - height);
container->resize(inner.width(), inner.height() - height);
bottom->resizeToWidth(inner.width());
}, bottom->lifetime());
container->show();
_webview = std::make_unique<WebviewWithLifetime>(
container.get(),
container,
Webview::WindowConfig{
.userDataPath = _userDataPath,
});
const auto raw = &_webview->window;
QObject::connect(container.get(), &QObject::destroyed, [=] {
QObject::connect(container, &QObject::destroyed, [=] {
if (_webview && &_webview->window == raw) {
_webview = nullptr;
if (_webviewProgress) {
@ -584,8 +586,6 @@ postEvent: function(eventType, eventData) {
}
};)");
_widget->showInner(std::move(container));
setupProgressGeometry();
return true;