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

[Bug]: SimpleForm 未知原因崩溃 #1610

Closed
engsr6982 opened this issue Jan 7, 2025 · 0 comments
Closed

[Bug]: SimpleForm 未知原因崩溃 #1610

engsr6982 opened this issue Jan 7, 2025 · 0 comments
Assignees
Labels
bug Related to software malfunction

Comments

@engsr6982
Copy link

engsr6982 commented Jan 7, 2025

Describe the bug

当玩家点击 SimpleForm 中的按钮,回调打开子表单时出现崩溃

目前我有两个插件都有此崩溃问题(0.13.5时都是正常的)
在LL 1.0.0-rc.1 到 rc.2 均复现。

我写了个最小复现代码,它能复现崩溃。

#include "ll/api/Expected.h"
#include "ll/api/command/Command.h"
#include "ll/api/command/CommandHandle.h"
#include "ll/api/command/CommandRegistrar.h"
#include "ll/api/command/Overload.h"
#include "ll/api/command/OverloadData.h"
#include "ll/api/form/SimpleForm.h"
#include "ll/api/mod/RegisterHelper.h"
#include "mc/server/commands/CommandOrigin.h"
#include "mc/world/actor/player/Player.h"


void FormB(Player& player);
void FormA(Player& player) {
    ll::form::SimpleForm fm("A");
    fm.setContent("A");
    fm.appendButton("Button 1", "textures/ui/anvil_icon", "path", [](Player& player) { FormB(player); });
    fm.appendButton("Button 2", "textures/ui/anvil_icon", "path", [](Player& player) { FormB(player); });
    fm.appendButton("Button 3", "textures/ui/anvil_icon", "path", [](Player& player) { FormB(player); });
    fm.sendTo(player);
}

void FormB(Player& player) {
    ll::form::SimpleForm fm("B");
    fm.setContent("B");
    fm.appendButton("Button 1", "textures/ui/icon_spring", "path", [](Player& player) { FormA(player); });
    fm.appendButton("Button 1", "textures/ui/icon_spring", "path", [](Player& player) { FormA(player); });
    fm.appendButton("Button 1", "textures/ui/icon_spring", "path", [](Player& player) { FormA(player); });
    fm.sendTo(player);
}


bool MyMod::enable() {
    getSelf().getLogger().debug("Enabling...");
    // Code for enabling the mod goes here.

    ll::command::CommandRegistrar::getInstance().getOrCreateCommand("test").overload().execute(
        [](CommandOrigin const& ori, CommandOutput& out) {
            auto ent = ori.getEntity();
            if (ent && ent->isPlayer()) {
                if (auto player = static_cast<Player*>(ent)) {
                    FormA(*player);
                }
            }
        }
    );
    return true;
}

当玩家执行命令test时,表单A会发送给玩家,玩家正常打开表单A,当玩家点击表单A中的按钮后服务端会崩溃。 这个崩溃CrashLogger无法捕获出原因,只显示unknown error。

To Reproduce

使用最小复现代码,执行命令 test,点击按钮,即可复现崩溃

PS:有时候不是点击按钮立即崩溃,有概率可以正常打开子表单,在子表单点击按钮返回主表单重新尝试,如果客户端未收到表单,此时服务端看似正常运行,当玩家再次执行test命令后,点击按钮就崩溃

Expected behavior

正常运行

Screenshots

image

Platform

win10

Version

1.21.50-10.766+37da480 with LeviLamina-1.0.0-rc.2+321071467.

Additional context

levilamina-mod-template.zip
最小复现代码(带已编译的dll,debug编译)

@engsr6982 engsr6982 added the bug Related to software malfunction label Jan 7, 2025
@engsr6982 engsr6982 changed the title [Bug]: SimpleForm 未知崩溃 [Bug]: SimpleForm 未知原因崩溃 Jan 7, 2025
@Dofes Dofes closed this as completed in ffc40f9 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Related to software malfunction
Development

No branches or pull requests

2 participants