mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: don't throw on bad icons in BrowserWindow constructor (#27463)
* fix: do not throw if NativeImage conversion fails. Throwing is an unannounced semver/major breaking change, so revert that behavior but keep the rest of the #26546 refactor.
This commit is contained in:
@@ -101,7 +101,7 @@ BaseWindow::BaseWindow(v8::Isolate* isolate,
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
v8::Local<v8::Value> icon;
|
||||
if (options.Get(options::kIcon, &icon)) {
|
||||
SetIcon(isolate, icon);
|
||||
SetIconImpl(isolate, icon, NativeImage::OnConvertError::kWarn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1003,8 +1003,15 @@ bool BaseWindow::SetThumbarButtons(gin_helper::Arguments* args) {
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void BaseWindow::SetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon) {
|
||||
SetIconImpl(isolate, icon, NativeImage::OnConvertError::kThrow);
|
||||
}
|
||||
|
||||
void BaseWindow::SetIconImpl(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> icon,
|
||||
NativeImage::OnConvertError on_error) {
|
||||
NativeImage* native_image = nullptr;
|
||||
if (!NativeImage::TryConvertNativeImage(isolate, icon, &native_image))
|
||||
if (!NativeImage::TryConvertNativeImage(isolate, icon, &native_image,
|
||||
on_error))
|
||||
return;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
@@ -223,6 +223,9 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
||||
bool SetThumbarButtons(gin_helper::Arguments* args);
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void SetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
|
||||
void SetIconImpl(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> icon,
|
||||
NativeImage::OnConvertError on_error);
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
typedef base::RepeatingCallback<void(v8::Local<v8::Value>,
|
||||
|
||||
Reference in New Issue
Block a user