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

单击 Combo 控件,程序崩溃 #46

Closed
roc1 opened this issue Jun 12, 2019 · 4 comments
Closed

单击 Combo 控件,程序崩溃 #46

roc1 opened this issue Jun 12, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@roc1
Copy link

roc1 commented Jun 12, 2019

问题现象

重现步骤

在例子 controls 工程 controls.xml 里添加一个 Combo 代码,如下:
<!-- Option --> <VBox> <Option class="circle_option_2" group="option_group" text="option1" margin="0,3,0,10" selected="true"/> <Option class="circle_option_2" group="option_group" text="option2" margin="0,3,0,10"/> <Option class="circle_option_2" group="option_group" text="option3" margin="0,3,0,10"/> </VBox> <!--我是添加的COMBO--> <HBox> <Combo height="30" bordersize="1" bordercolor="red"> <ListContainerElement height="20" text="t1" /> <ListContainerElement height="20" text="t1" /> </Combo> </HBox> <!-- List --> <VListBox class="list" name="list" padding="5,3,5,3">
2.
点击 Combo 就会崩溃。
3.
在这里崩溃了
CPoint ptOldOrg = pRender->OffsetWindowOrg(ptOffset);

@roc1
Copy link
Author

roc1 commented Jun 13, 2019

找到原因了,在 global.xml 里添加一个<TextColor name="combobox_border" value="#ffe4e7eb"/> 就可以了。
如果没有这个,DWORD GlobalManager::GetTextColor(const std::wstring& strName) { // 必须在global.xml中提前定义到颜色值 ASSERT(m_mapTextColor[strName] != 0); return m_mapTextColor[strName]; }
这里 ASSERT 会弹窗,然后 ComboWnd 会被 KILLFOCUS,然后自己 delete 自己,然后莫名其名的还有 WM_PAINT 消息没有被处理,然后处理的时候,发现 this 已经无效了,就崩溃了。

我用的是 vs2019,不知道为什么 ASSERT 不提示对话框。

@roc1
Copy link
Author

roc1 commented Jun 13, 2019

应该不是 vs2019 ASSERT 不显示对话框的问题。ASSERT 的对话框还没来得及显示,程序就崩溃了。

@nmgwddj
Copy link
Collaborator

nmgwddj commented Jun 13, 2019

@caop3ng 这个问题是需要改正的,尽量不在核心代码中出现常量的颜色值,感谢您的反馈。

@nmgwddj nmgwddj added the bug Something isn't working label Jun 13, 2019
@roc1
Copy link
Author

roc1 commented Jun 13, 2019

@nmgwddj 默认的 global.xml 里没有 combobox_border 色值。

nmgwddj added a commit that referenced this issue Jun 18, 2019
 - Added combo and single line text control sample to `controls` project.
 - Modified RichEdit.md to remove duplicate attributes.

Signed-off-by: jiajia_deng <[email protected]>
@nmgwddj nmgwddj closed this as completed Jun 18, 2019
QWarGod pushed a commit to QWarGod/NIM_Duilib_Framework that referenced this issue Jun 18, 2021
 - Added combo and single line text control sample to `controls` project.
 - Modified RichEdit.md to remove duplicate attributes.

Signed-off-by: jiajia_deng <[email protected]>
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