Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve crash after deconstruction #423

Closed
ljnhst opened this issue Dec 8, 2023 · 1 comment
Closed

Resolve crash after deconstruction #423

ljnhst opened this issue Dec 8, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ljnhst
Copy link

ljnhst commented Dec 8, 2023

在WindowManagerPlugin析构时应将channel置为空指针。在析构之后还传递窗口消息,在invokeMethod方法内会出现messenger_指针异常问题。复现方法为在退出应用前调用关闭窗口的方法,再退出应用。

下面为我解决该问题添加的指针处理:

WindowManagerPlugin::~WindowManagerPlugin() {
  registrar->UnregisterTopLevelWindowProcDelegate(window_proc_id);
  channel = nullptr;
}

void WindowManagerPlugin::_EmitEvent(std::string eventName) {
  if (channel) {
    flutter::EncodableMap args = flutter::EncodableMap();
    args[flutter::EncodableValue("eventName")] =
        flutter::EncodableValue(eventName);
    channel->InvokeMethod("onEvent",
                          std::make_unique<flutter::EncodableValue>(args));
  }
}
@lijy91 lijy91 self-assigned this May 18, 2024
@lijy91 lijy91 added the bug Something isn't working label May 18, 2024
lijy91 added a commit that referenced this issue May 18, 2024
@lijy91
Copy link
Member

lijy91 commented May 18, 2024

Fixed in this commit 8fa23db

@lijy91 lijy91 closed this as completed May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants