![]() |
CXTButton crashes |
Post Reply ![]() |
Author | |
rock ![]() Groupie ![]() Joined: 27 October 2005 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() Posted: 09 November 2005 at 2:46pm |
I have discoved that if I try to use more than one CXTButton in any of my dialog box classes, my application will crash inside of XTPImageManager.cpp in the CXTPImageManagerIconHandle::IsEmpty() function. I've also found out that if I try to use a CXTButton in a CView derived class, I get an assertion error when calling CXTButton::SetIcon() when the function SAFE_DELETE(m_pIcon) is called. The code I use is similar to what I found in the Explorer GUI sample: myheader file: CImageList m_ilButton: CXTButton m_addBtn; my cpp file: m_ilButton.Create(XT_IDB_BTN_OUT, 16, 1, RGB(255,0,255)); if (m_btnAdd.Create(NULL, WS_VISIBLE | BS_ICON | BS_OWNERDRAW | BS_CENTER | BS_VCENTER, CRect(0,0,0,0), this, IDC_BTN_CREATE)){ m_btnAdd.SetIcon(CSize(16, 15), m_ilButton.ExtractIcon(2)); m_btnAdd.SetTheme(xtThemeDefault); m_btnAdd.SetXButtonStyle(BS_XT_WINXP_COMPAT); } I added a watch to m_btnAdd.m_pIcon and it is NULL before I enter SetIcon(), but then once I'm into the CXTButton code it is no longer NULL. I've tried increasing the application stack size but there is no difference, it still crashes. Have I missed something obvious. I'm using Visual Studio 2003. |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Do you have standard structure package - 8? |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
rock ![]() Groupie ![]() Joined: 27 October 2005 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
That thought did occur to me after I got away from working on it and was able to think about it. And no, our app has it set to 1. Unfortunately the engine dll for our app requires us to have structure package set to 1. Is there any harm in recompiling the CodeJock libraries with the setting at 1 instead of 8?
|
|
![]() |
|
rock ![]() Groupie ![]() Joined: 27 October 2005 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
A simplier soultion that works fine rather than recompile the CodeJock libraries was for me to add the following to my stdafx.h file #pragma pack(push, 8)#include <XTToolkitPro.h> // Xtreme Toolkit Pro component library #pragma pack(pop) |
|
![]() |
|
jigarmehtamscit ![]() Groupie ![]() ![]() Joined: 29 October 2005 Location: India Status: Offline Points: 64 |
![]() ![]() ![]() ![]() ![]() |
Hi rock,
can you please explain what these statements does ?? And how this solves the problem ? |
|
Regards,
Jigar Mehta |
|
![]() |
|
rock ![]() Groupie ![]() Joined: 27 October 2005 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Jigar, I'll do my best to explain. The "Struct Member Alignment" option in the C++ Code Generation section of the project properties tells the compiler how to pack the members of structures in memory based on byte boundries. My application has this set to 1 byte. While the default for Visual Studio apps is set to 8; which is also what the XTreme libraries are set to. Passing data between 2 sets of code with different settings could cause memory corruption. The #pragma pack(push, 8) tells the compiler to use 8 byte alignment for any code following that statement. In this case the XTreme Toolkit libs. Then #pragma pack(pop) just restores the orignal setting (in my case 1 byte alignment) for the remainder of the code or until another #pragma or other instruction is encountered. With these statements, any data passed to the XTreme Libs uses 8 byte alignment while the rest of my code uses 1 byte (I hope) I'm neither a teacher or an expert, but I hope this helps. |
|
![]() |
|
jigarmehtamscit ![]() Groupie ![]() ![]() Joined: 29 October 2005 Location: India Status: Offline Points: 64 |
![]() ![]() ![]() ![]() ![]() |
perfect rock.. you are a good teacher indeed..
I understood it well.. But one question that arise in my mind that, if a structure object that is passed to xtreme libs as we as used by your application.. so, how will that be packed ?? will that on the fly change the packing type ? (I dont think that would be the way..) And what I understood by your answer is, If we want to have our data to be differently aligned for some snippet of code, we need to pack that snippet accordingly by the statement, #pragma pack(push, X) Tell me if i am wrong anywhere.. Thx for the valuable information.. |
|
Regards,
Jigar Mehta |
|
![]() |
|
rock ![]() Groupie ![]() Joined: 27 October 2005 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
It would be my understanding that the different byte alignment would only apply to the functions within the scope of the #pragma statements. You are right about the #pragma pack(push, X) statements This link might also provide more information: http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/vccore/html/_core_.2f.zp.asp |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |