Skip to content

Commit 1d1d150

Browse files
committed
fix: Video memory explosion caused by randomly clicking on dock plugins
The size of the popup window is not initialized and limited to the maximum value, resulting in excessive memory usage due to excessive size in some cases log: as title
1 parent 27a59d6 commit 1d1d150

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

frame/popupwindow.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,20 @@ DS_BEGIN_NAMESPACE
88
PopupWindow::PopupWindow(QWindow *parent)
99
: QQuickWindowQmlImpl(parent)
1010
{
11-
setMinimumHeight(10);
12-
setMinimumWidth(10);
11+
// minimum size is 1x1 to prevent protocols error on wayland
12+
setMinimumSize(QSize(1, 1));
13+
14+
// maximum size is the screen size, to prevent the window from being too large and causing
15+
// the video memory to explode
16+
auto setMaximumSize = [this]() {
17+
auto screen = QWindow::screen();
18+
if (screen) {
19+
this->setMaximumSize(screen->size());
20+
}
21+
};
22+
23+
connect(this, &QWindow::screenChanged, this, setMaximumSize);
24+
setMaximumSize();
1325
}
1426

1527
void PopupWindow::mouseReleaseEvent(QMouseEvent *event)

panels/dock/pluginmanagerextension.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ void PluginScale::wp_fractional_scale_v1_destroy(Resource *resource)
8383
deleteLater();
8484
}
8585

86-
PluginSurface::PluginSurface(PluginManager* manager, const QString& pluginId, const QString& itemKey, const QString &displayName, int pluginFlags, int pluginType, int sizePolicy, QWaylandSurface *surface, const QWaylandResource &resource)
86+
PluginSurface::PluginSurface(PluginManager *manager,
87+
const QString &pluginId,
88+
const QString &itemKey,
89+
const QString &displayName,
90+
int pluginFlags,
91+
int pluginType,
92+
int sizePolicy,
93+
QWaylandSurface *surface,
94+
const QWaylandResource &resource)
8795
: m_manager(manager)
8896
, m_surface(surface)
8997
, m_itemKey(itemKey)
@@ -93,6 +101,8 @@ PluginSurface::PluginSurface(PluginManager* manager, const QString& pluginId, co
93101
, m_pluginType(pluginType)
94102
, m_sizePolicy(sizePolicy)
95103
, m_margins(0)
104+
, m_height(1)
105+
, m_width(1)
96106
{
97107
init(resource.resource());
98108
setExtensionContainer(surface);
@@ -239,12 +249,21 @@ void PluginSurface::plugin_source_size(Resource *resource, int32_t width, int32_
239249
}
240250
}
241251

242-
PluginPopup::PluginPopup(PluginManager* manager, const QString &pluginId, const QString &itemKey, int x, int y, int popupType, QWaylandSurface *surface, const QWaylandResource &resource)
252+
PluginPopup::PluginPopup(PluginManager *manager,
253+
const QString &pluginId,
254+
const QString &itemKey,
255+
int x,
256+
int y,
257+
int popupType,
258+
QWaylandSurface *surface,
259+
const QWaylandResource &resource)
243260
: m_manager(manager)
244261
, m_surface(surface)
245262
, m_pluginId(pluginId)
246263
, m_itemKey(itemKey)
247264
, m_popupType(popupType)
265+
, m_height(1)
266+
, m_width(1)
248267
{
249268
init(resource.resource());
250269
setExtensionContainer(surface);

0 commit comments

Comments
 (0)