File tree Expand file tree Collapse file tree 5 files changed +206
-40
lines changed Expand file tree Collapse file tree 5 files changed +206
-40
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class EventChannel {
9292 std::cerr << " Failed to cancel existing stream: "
9393 << (error->error_code ) << " , "
9494 << (error->error_message ) << " , "
95- << (error->error_details );
95+ << (error->error_details . get () );
9696 }
9797 }
9898 is_listening = true ;
@@ -106,7 +106,7 @@ class EventChannel {
106106 if (error) {
107107 result = codec->EncodeErrorEnvelope (error->error_code ,
108108 error->error_message ,
109- error->error_details );
109+ error->error_details . get () );
110110 } else {
111111 result = codec->EncodeSuccessEnvelope ();
112112 }
@@ -119,7 +119,7 @@ class EventChannel {
119119 if (error) {
120120 result = codec->EncodeErrorEnvelope (error->error_code ,
121121 error->error_message ,
122- error->error_details );
122+ error->error_details . get () );
123123 } else {
124124 result = codec->EncodeSuccessEnvelope ();
125125 }
Original file line number Diff line number Diff line change 55#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_
66#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_
77
8+ #include < memory>
9+ #include < string>
10+
811#include " event_sink.h"
912
1013namespace flutter {
@@ -13,16 +16,16 @@ class EncodableValue;
1316
1417template <typename T = EncodableValue>
1518struct StreamHandlerError {
16- const std::string& error_code;
17- const std::string& error_message;
18- const T* error_details;
19+ const std::string error_code;
20+ const std::string error_message;
21+ const std::unique_ptr<T> error_details;
1922
20- StreamHandlerError (const std::string& error_code,
21- const std::string& error_message,
22- const T* error_details)
23+ StreamHandlerError (const std::string error_code,
24+ const std::string error_message,
25+ std::unique_ptr<T>&& error_details)
2326 : error_code(error_code),
2427 error_message (error_message),
25- error_details(error_details) {}
28+ error_details(std::move( error_details) ) {}
2629};
2730
2831// Handler for stream setup and teardown requests.
Original file line number Diff line number Diff line change @@ -91,9 +91,10 @@ class MethodChannel {
9191 // Registers a handler that should be called any time a method call is
9292 // received on this channel. A null handler will remove any previous handler.
9393 //
94- // Note that the MethodChannel does not own the handler, and will not
95- // unregister it on destruction, so the caller is responsible for
96- // unregistering explicitly if it should no longer be called.
94+ // The handler will be owned by the underlying BinaryMessageHandler.
95+ // Destroying the MethodChannel will not unregister the handler, so
96+ // the caller is responsible for unregistering explicitly if the handler
97+ // stops being valid before the engine is destroyed.
9798 void SetMethodCallHandler (MethodCallHandler<T> handler) const {
9899 if (!handler) {
99100 messenger_->SetMessageHandler (name_, nullptr );
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ EncodableValue StandardCodecSerializer::ReadValue(
9898void StandardCodecSerializer::WriteValue (const EncodableValue& value,
9999 ByteStreamWriter* stream) const {
100100 stream->WriteByte (static_cast <uint8_t >(EncodedTypeForValue (value)));
101- // TODO(cbracken): Consider replacing this this with std::visit.
101+ // TODO(cbracken): Consider replacing this with std::visit.
102102 switch (value.index ()) {
103103 case 0 :
104104 case 1 :
You can’t perform that action at this time.
0 commit comments