Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent Invalid Pointer when loading extensions on Windows, rename with_extension_path -> with_extensions_path #1421

Merged
merged 6 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/extension_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": "patch"
---

Fix extension loading on Windows and rename `with_extension_path` to `with_extensions_path`.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ pub trait WebViewBuilderExtWindows {
/// Set the path from which to load extensions from. Extensions stored in this path should be unpacked.
///
/// Does nothing if browser extensions are disabled. See [`with_browser_extensions_enabled`](Self::with_browser_extensions_enabled)
fn with_extension_path(self, path: impl Into<PathBuf>) -> Self;
fn with_extensions_path(self, path: impl Into<PathBuf>) -> Self;
Copy link
Member

Choose a reason for hiding this comment

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

let's revert this naming change so I can release the fix as a patch version, we can rename in another PR afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha 👍

}

#[cfg(windows)]
Expand Down Expand Up @@ -1349,7 +1349,7 @@ impl WebViewBuilderExtWindows for WebViewBuilder<'_> {
})
}

fn with_extension_path(self, path: impl Into<PathBuf>) -> Self {
fn with_extensions_path(self, path: impl Into<PathBuf>) -> Self {
self.and_then(|mut b| {
b.platform_specific.extension_path = Some(path.into());
Ok(b)
Expand Down Expand Up @@ -1469,7 +1469,7 @@ pub trait WebViewBuilderExtUnix<'a> {
W: gtk::prelude::IsA<gtk::Container>;

/// Set the path from which to load extensions from.
fn with_extension_path(self, path: impl Into<PathBuf>) -> Self;
fn with_extensions_path(self, path: impl Into<PathBuf>) -> Self;
}

#[cfg(any(
Expand All @@ -1490,7 +1490,7 @@ impl<'a> WebViewBuilderExtUnix<'a> for WebViewBuilder<'a> {
.map(|webview| WebView { webview })
}

fn with_extension_path(self, path: impl Into<PathBuf>) -> Self {
fn with_extensions_path(self, path: impl Into<PathBuf>) -> Self {
self.and_then(|mut b| {
b.platform_specific.extension_path = Some(path.into());
Ok(b)
Expand Down
3 changes: 2 additions & 1 deletion src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,9 @@ impl InnerWebView {
for entry in fs::read_dir(extension_path)? {
let path = entry?.path();
let path_hs = HSTRING::from(path.as_path());
let handler = ProfileAddBrowserExtensionCompletedHandler::create(Box::new(|_, _| Ok(())));

profile.AddBrowserExtension(&path_hs, None)?;
profile.AddBrowserExtension(&path_hs, &handler)?;
}

Ok(())
Expand Down