mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:18:13 +00:00
LibGfx: Don't encode invalid Gfx::ShareableBitmap as IPC::File
IPC::File should only be used when there's an actual file to pass. Invalid ShareableBitmaps don't have a backing file, so fix this by first encoding a "valid" flag.
This commit is contained in:
parent
64610ca80e
commit
7c1df68be3
1 changed files with 10 additions and 0 deletions
|
@ -44,6 +44,9 @@ namespace IPC {
|
|||
|
||||
bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
|
||||
{
|
||||
encoder << shareable_bitmap.is_valid();
|
||||
if (!shareable_bitmap.is_valid())
|
||||
return true;
|
||||
encoder << IPC::File(shareable_bitmap.anon_fd());
|
||||
encoder << shareable_bitmap.width();
|
||||
encoder << shareable_bitmap.height();
|
||||
|
@ -52,6 +55,13 @@ bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
|
|||
|
||||
bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
|
||||
{
|
||||
bool valid = false;
|
||||
if (!decoder.decode(valid))
|
||||
return false;
|
||||
if (!valid) {
|
||||
shareable_bitmap = {};
|
||||
return true;
|
||||
}
|
||||
IPC::File anon_file;
|
||||
Gfx::IntSize size;
|
||||
if (!decoder.decode(anon_file))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue