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

Fix: 修复在 inigraph() 之前调用 newimage() 会引起程序崩溃的问题 #153

Merged

Conversation

yixy-only
Copy link
Collaborator

原因: 在创建图像时创建了 GDI+ 对象但并未在此之前对 GDI+ 进行初始化 。#59 中引入(083423f)

 原因: 在创建图像时创建了 GDI+ 对象但并未在此之前对 GDI+ 进行初始化 。wysaid#59 中引入(083423f)
@yixy-only yixy-only changed the title Fix: 修复的在 inigraph() 之前调用 newimage() 会引起程序崩溃的问题 Fix: 修复在 inigraph() 之前调用 newimage() 会引起程序崩溃的问题 Apr 17, 2024
@wysaid
Copy link
Owner

wysaid commented Apr 17, 2024

好家伙呀...
有测过这种代码吗:

#include <graphics.h>
PIMAGE* image = newimage(123,456);

int main()
{
    initgraph(...);
   // ...
}

@wysaid
Copy link
Owner

wysaid commented Apr 17, 2024

之前遇到的主要问题就是这种全局变量的形式, 此时 main 函数都没执行, initgraph 肯定没有。
如果这个解决了的话, class Image 就可以放出来了。
之前的问题是很多人喜欢用全局变量, class Image 直接创建实体会有问题

@yixy-only
Copy link
Collaborator Author

yixy-only commented Apr 17, 2024

好家伙呀... 有测过这种代码吗:

#include <graphics.h>
PIMAGE* image = newimage(123,456);

int main()
{
    initgraph(...);
   // ...
}

@wysaid 这个在 EGE 20.08 就允许这种写法了,可以不创建窗口直接绘图,只绘图不显示,用来导出图像、数据处理啥的。只是在后面的某次修改中改动到了 IMAGE 初始化部分,使用了 GDI+ 对象,但是 GDI+ 对象创建之前是需要先进行 GDI+ 初始化的,那次改动没考虑到这点导致程序崩溃。

@chirsz-ever chirsz-ever merged commit 176658e into wysaid:master Apr 18, 2024
1 check passed
@yixy-only yixy-only deleted the fix_crash_when_newimage_before_initgraph branch April 24, 2024 11:31
@yixy-only yixy-only self-assigned this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants