File tree Expand file tree Collapse file tree 6 files changed +26
-15
lines changed
src/flutter/shell/platform/common/client_wrapper Expand file tree Collapse file tree 6 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,13 @@ class EncodableValue : public internal::EncodableValueVariant {
215215 }
216216 return std::get<int64_t >(*this );
217217 }
218+
219+ // Explicitly provide operator<, delegating to std::variant's operator<.
220+ // There are issues with with the way the standard library-provided
221+ // < and <=> comparisons interact with classes derived from variant.
222+ friend bool operator <(const EncodableValue& lhs, const EncodableValue& rhs) {
223+ return static_cast <const super&>(lhs) < static_cast <const super&>(rhs);
224+ }
218225};
219226
220227} // namespace flutter
Original file line number Diff line number Diff line change @@ -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 @@ -49,8 +49,8 @@ class PluginRegistrar {
4949 // Takes ownership of |plugin|.
5050 //
5151 // Plugins are not required to call this method if they have other lifetime
52- // management, but this is a convient place for plugins to be owned to ensure
53- // that they stay valid for any registered callbacks.
52+ // management, but this is a convenient place for plugins to be owned to
53+ // ensure that they stay valid for any registered callbacks.
5454 void AddPlugin (std::unique_ptr<Plugin> plugin);
5555
5656 protected:
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: Consider replacing this this with a std::visitor .
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