Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b66a876

Browse files
authored
Fix incorrect C++ return value of PictureRecorder::endRecording() (#47645)
The Dart code has the following declaration: ```dart @Native<Void Function(Pointer<Void>, Handle)>(symbol: 'PictureRecorder::endRecording') external void _endRecording(_NativePicture outPicture); ``` => Dart doesn't expect to get a return value, so C++ shouldn't return anything.
1 parent ec20731 commit b66a876

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

lib/ui/painting/picture.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ namespace flutter {
2626

2727
IMPLEMENT_WRAPPERTYPEINFO(ui, Picture);
2828

29-
fml::RefPtr<Picture> Picture::Create(Dart_Handle dart_handle,
30-
sk_sp<DisplayList> display_list) {
29+
void Picture::CreateAndAssociateWithDartWrapper(
30+
Dart_Handle dart_handle,
31+
sk_sp<DisplayList> display_list) {
3132
FML_DCHECK(display_list->isUIThreadSafe());
3233
auto canvas_picture = fml::MakeRefCounted<Picture>(std::move(display_list));
33-
3434
canvas_picture->AssociateWithDartWrapper(dart_handle);
35-
return canvas_picture;
3635
}
3736

3837
Picture::Picture(sk_sp<DisplayList> display_list)

lib/ui/painting/picture.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class Picture : public RefCountedDartWrappable<Picture> {
2020

2121
public:
2222
~Picture() override;
23-
static fml::RefPtr<Picture> Create(Dart_Handle dart_handle,
24-
sk_sp<DisplayList> display_list);
23+
static void CreateAndAssociateWithDartWrapper(
24+
Dart_Handle dart_handle,
25+
sk_sp<DisplayList> display_list);
2526

2627
sk_sp<DisplayList> display_list() const { return display_list_; }
2728

lib/ui/painting/picture_recorder.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,18 @@ sk_sp<DisplayListBuilder> PictureRecorder::BeginRecording(SkRect bounds) {
3131
return display_list_builder_;
3232
}
3333

34-
fml::RefPtr<Picture> PictureRecorder::endRecording(Dart_Handle dart_picture) {
34+
void PictureRecorder::endRecording(Dart_Handle dart_picture) {
3535
if (!canvas_) {
36-
return nullptr;
36+
return;
3737
}
3838

39-
fml::RefPtr<Picture> picture;
40-
41-
picture = Picture::Create(dart_picture, display_list_builder_->Build());
39+
Picture::CreateAndAssociateWithDartWrapper(dart_picture,
40+
display_list_builder_->Build());
4241
display_list_builder_ = nullptr;
4342

4443
canvas_->Invalidate();
4544
canvas_ = nullptr;
4645
ClearDartWrapper();
47-
return picture;
4846
}
4947

5048
} // namespace flutter

lib/ui/painting/picture_recorder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PictureRecorder : public RefCountedDartWrappable<PictureRecorder> {
2222
~PictureRecorder() override;
2323

2424
sk_sp<DisplayListBuilder> BeginRecording(SkRect bounds);
25-
fml::RefPtr<Picture> endRecording(Dart_Handle dart_picture);
25+
void endRecording(Dart_Handle dart_picture);
2626

2727
void set_canvas(fml::RefPtr<Canvas> canvas) { canvas_ = std::move(canvas); }
2828

0 commit comments

Comments
 (0)