mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: handle a nil backgroundColor in win.getBackgroundColor() (#28188)
* fix: handle a nil backgroundColor in win.getBackgroundColor() * spec: add crash case * fix: update to fix native_views transparent color * chore: fix lint Co-authored-by: Samuel Attard <sattard@slack-corp.com> Co-authored-by: Samuel Attard <sam@electronjs.org>
This commit is contained in:
@@ -1197,8 +1197,10 @@ void NativeWindowMac::SetBackgroundColor(SkColor color) {
|
||||
}
|
||||
|
||||
SkColor NativeWindowMac::GetBackgroundColor() {
|
||||
return skia::CGColorRefToSkColor(
|
||||
[[[window_ contentView] layer] backgroundColor]);
|
||||
CGColorRef color = [[[window_ contentView] layer] backgroundColor];
|
||||
if (!color)
|
||||
return SK_ColorTRANSPARENT;
|
||||
return skia::CGColorRefToSkColor(color);
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetHasShadow(bool has_shadow) {
|
||||
|
||||
@@ -956,7 +956,10 @@ bool NativeWindowViews::IsTabletMode() const {
|
||||
}
|
||||
|
||||
SkColor NativeWindowViews::GetBackgroundColor() {
|
||||
return root_view_->background()->get_color();
|
||||
auto* background = root_view_->background();
|
||||
if (!background)
|
||||
return SK_ColorTRANSPARENT;
|
||||
return background->get_color();
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
transparent: true
|
||||
});
|
||||
mainWindow.getBackgroundColor();
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow();
|
||||
setTimeout(() => app.quit());
|
||||
});
|
||||
Reference in New Issue
Block a user