зеркало из https://github.com/electron/electron.git
fix: potential crash when setting vibrancy (#29677)
This commit is contained in:
Родитель
81795744cf
Коммит
2ae7e04598
|
@ -1360,8 +1360,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||
return;
|
||||
}
|
||||
|
||||
vibrancy_type_ = type;
|
||||
|
||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||
if (effect_view == nil) {
|
||||
effect_view = [[[NSVisualEffectView alloc]
|
||||
|
@ -1390,7 +1388,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||
node::Environment* env =
|
||||
node::Environment::GetCurrent(JavascriptEnvironment::GetIsolate());
|
||||
|
||||
NSVisualEffectMaterial vibrancyType;
|
||||
NSVisualEffectMaterial vibrancyType{};
|
||||
if (type == "appearance-based") {
|
||||
EmitWarning(env, "NSVisualEffectMaterialAppearanceBased" + dep_warn,
|
||||
"electron");
|
||||
|
@ -1447,8 +1445,10 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||
}
|
||||
}
|
||||
|
||||
if (vibrancyType)
|
||||
if (vibrancyType) {
|
||||
vibrancy_type_ = type;
|
||||
[effect_view setMaterial:vibrancyType];
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetWindowButtonVisibility(bool visible) {
|
||||
|
|
|
@ -1609,6 +1609,13 @@ describe('BrowserWindow module', () => {
|
|||
w.setVibrancy('' as any);
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('does not crash if vibrancy is set to an invalid value', () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
expect(() => {
|
||||
w.setVibrancy('i-am-not-a-valid-vibrancy-type' as any);
|
||||
}).to.not.throw();
|
||||
});
|
||||
});
|
||||
|
||||
ifdescribe(process.platform === 'darwin')('trafficLightPosition', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче