Skip to content

fix(python): 修复 Context.wait_freezes 的 Rect 句柄传递,改用 RectBuffer 管理#1175

Merged
MistEO merged 4 commits intomainfrom
fix/py_wait_freezes
Mar 4, 2026
Merged

fix(python): 修复 Context.wait_freezes 的 Rect 句柄传递,改用 RectBuffer 管理#1175
MistEO merged 4 commits intomainfrom
fix/py_wait_freezes

Conversation

@Windsland52
Copy link
Member

@Windsland52 Windsland52 commented Mar 4, 2026

Summary by Sourcery

Bug Fixes:

  • 通过在框架中创建 Rect 句柄,并始终在 finally 块中销毁它们,修复了 Context.wait_freezes 中 Rect 句柄的生命周期问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix Rect handle lifecycle in Context.wait_freezes by creating handles through the framework and always destroying them in a finally block.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿,我已经审查了你的修改,看起来很棒!


Sourcery 对开源项目是免费的 —— 如果你觉得我们的评审对你有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@MistEO MistEO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

顺便可以让 AI 给补点单测,test 里的

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Python binding for Context.wait_freezes to correctly manage the lifecycle of the native Rect handle passed into MaaContextWaitFreezes, avoiding invalid handle usage and ensuring cleanup.

Changes:

  • Allocate the ROI rect via MaaRectCreate() instead of constructing a ctypes handle directly.
  • Ensure the rect handle is always released via MaaRectDestroy() in a finally block.
  • Early-return False if rect creation fails.

@MistEO
Copy link
Member

MistEO commented Mar 4, 2026

等一个 CI

@Windsland52 Windsland52 changed the title fix(python): 修复 Context.wait_freezes 中 Rect 句柄创建与释放 fix(python): 修复 Context.wait_freezes 的 Rect 句柄传递,改用 RectBuffer 管理 Mar 4, 2026
@MistEO MistEO merged commit 8e103e8 into main Mar 4, 2026
14 checks passed
@MistEO MistEO deleted the fix/py_wait_freezes branch March 4, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants