stdware / qwindowkit

Cross-platform frameless window framework for Qt. Support Windows, macOS, Linux.
Apache License 2.0
490 stars 78 forks source link

Fix: fix null pointer in examples #30

Closed KangLin closed 7 months ago

wangwenx190 commented 7 months ago

How could menu be null?

KangLin commented 7 months ago

YES. you are return before instance menu.

At 2024-01-30 09:54:31, "Yuhang Zhao" @.***> wrote:

How could menu be null?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wangwenx190 commented 7 months ago

I don't think so. If we are accessing a null pointer, we would experience a crash already, but that didn't happen.

KangLin commented 7 months ago

https://github.com/stdware/qwindowkit/blob/03605a234142933dc49f1a6b2fbf49ba007d87f8/examples/mainwindow/mainwindow.cpp#L122

在这里加上 return;

KangLin commented 7 months ago

简单的说,你没有考虑异常情况。

wangwenx190 commented 7 months ago

这个“异常情况”本不存在,是你非要加return造成的。可以看出你是在本地测试一些东西,那么你在本地修改就好了,不需要提交到这个仓库。