Skip to content

[Bug反馈] closegraph() 函数对于上下文环境的清理不够干净 #306

@Anglebase

Description

@Anglebase

Bug

当我编写 Rust xege-ffi的安全封装时,发现当应用程序第二次创建绘图环境时,窗口初始化模式不会生效:

use std::{thread::sleep, time::Duration};
use xege::*;

fn main() {
    let xege = initgraph(640, 480, Init::Default).unwrap();
    sleep(Duration::from_secs(5));
    xege.closegraph();
    sleep(Duration::from_secs(5));
    let xege = initgraph(640, 480, Init::NoBorder).unwrap();
    sleep(Duration::from_secs(5));
    xege.closegraph();
}

以上代码仅是Rust风格封装,与C++的xege库同名函数功能相同
推测是closegraph()函数未对窗口类进行注销,导致重复使用了第一次创建的窗口类

可能的解决方案

closegraph()中添加窗口类的注销操作

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions