Skip to content

Stability and Memory Safety Improvements#13

Open
niutech wants to merge 1 commit intomainfrom
fix-leaks-and-crashes-7958240601656317970
Open

Stability and Memory Safety Improvements#13
niutech wants to merge 1 commit intomainfrom
fix-leaks-and-crashes-7958240601656317970

Conversation

@niutech
Copy link
Owner

@niutech niutech commented Feb 11, 2026

This submission addresses several critical and non-critical issues in the Split Browser codebase:

  1. Crash Prevention: Added null-pointer checks for currentWebView() in MainWindow's slots. Previously, actions like toggling fullscreen or adding a bookmark would crash the application if no tabs were open.

  2. Memory Leak Fixes:

    • COM/Win32: Fixed a leak in win32_edge_engine where LPWSTR strings from WebView2 were not freed with CoTaskMemFree.
    • Heap Management: Changed get_title() and get_url() to return class-managed strings instead of leaking new char[].
    • JS Bindings: Implemented a destructor in the webview class to clean up its bindings map. Added a safety mechanism to correctly identify and delete sync_binding_ctx_t pointers while avoiding user-provided pointers.
    • Static Managers: Added MainWindow::cleanup() to properly delete the static HistoryManager and BookmarksManager instances upon application exit.
  3. Code Quality & UI:

    • URL Handling: Refactored sanitizeUrl to use QUrl::fromUserInput, making it significantly more robust than the previous hardcoded TLD-based logic.
    • Responsiveness: Removed a 500ms blocking sleep in clearData() that was unnecessarily freezing the UI thread.
    • Readability: Replaced magic numbers in event filters with standard Qt enum constants (e.g., QEvent::FocusIn).
    • I18n: Wrapped hardcoded user-facing strings in tr() and adopted the recommended .arg() pattern for variable interpolation in translations.

These changes collectively improve the stability, performance, and maintainability of the application.


PR created automatically by Jules for task 7958240601656317970 started by @niutech

- Added null checks for currentWebView() in MainWindow to prevent crashes.
- Fixed memory leaks in webview.h (win32_edge_engine and webview class).
- Resolved static manager leaks in MainWindow and main.cpp.
- Improved URL sanitization using QUrl::fromUserInput.
- Replaced magic numbers with named constants in QNativeWebView.
- Enhanced internationalization (i18n) by wrapping strings in tr().
- Removed blocking sleep in clearData().
- Improved binding management in webview class to avoid leaks on overwrite.
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant