Bug 513430 - KWin crashes when a window has the signal `maximizedAboutToChange`
Summary: KWin crashes when a window has the signal `maximizedAboutToChange`
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: scripts (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-16 10:08 UTC by jesuscarclem30
Modified: 2025-12-16 11:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jesuscarclem30 2025-12-16 10:08:26 UTC
SUMMARY
When a window is assigned the “maximizedAboutToChange” signal in a KWin script and triggers the event when maximized, in certain cases, specifically when the window is in “MaximizeMode.MaximizeFull,” kwin crashes. 

STEPS TO REPRODUCE
1. Create a KWin script 
2. Add `maximizedAboutToChange` signal to any window 
3. Trigger event (maximize window)

OBSERVED RESULT
KWin crashes 

EXPECTED RESULT
No crash

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.5.4

ADDITIONAL INFORMATION
Log:
```
kwin_wayland[1649087]:          "onWindowMaximizedStateChanged@:99"
kwin_wayland[1649087]: <Unknown File>:99: TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.
```
Comment 2 Vlad Zahorodnii 2025-12-16 10:36:20 UTC
```js
workspace.windowAdded.connect(window => {
    window.maximizedAboutToChange.connect(mode => console.log("whatsup", mode));
});
```

works for me

```
js: whatsup 3
js: whatsup 0
```

can you attach a simple script to the bug report that reproduces the issue?
Comment 3 jesuscarclem30 2025-12-16 10:46:32 UTC
The error occurs occasionally. I can't tell you exactly when it happens; it just shows the error in the log. 

```js
window.maximizedAboutToChange.connect((mode) => {
      onMaximizeChange(mode, window);
    });
  }

  function onMaximizeChange(mode, window) {
    if (mode !== 0) {
      return;
    }
    //DO STUFF
  }
```
Comment 4 Vlad Zahorodnii 2025-12-16 10:53:26 UTC
Maybe the `window` object is not valid or something? If kwin crashes, can you share a backtrace please?
Comment 5 jesuscarclem30 2025-12-16 11:06:45 UTC
More logs

```
Dec 16 02:04:35 kwin_wayland[1649087]: QDBusConnection: couldn't handle call to Teardown, no slot matched
Dec 16 02:04:35 kwin_wayland[1649087]: Could not find slot Krunner1Adaptor::Teardown
Dec 16 02:05:45 kwin_wayland[1649087]: "Could not convert argument 0 from undefined to QList<qulonglong>"
Dec 16 02:05:45 kwin_wayland[1649087]:          "onWindowMaximizedStateChanged@:99"
Dec 16 02:05:45 kwin_wayland[1649087]: <Unknown File>:99: TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.
```
`MaximizeMode` was `undefined` 
- "Could not convert argument 0 from undefined to QList<qulonglong>"

`Window` object is valid and not `undefined`

This only happens in specific cases, when the window changes state to maximized but does not return a `mode`
Comment 6 jesuscarclem30 2025-12-16 11:35:43 UTC
Ok nevermind is a problem with my code, `maximizedAboutToChange` is working 
Sorry!