Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - Crash on PropertyGrid delete
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Crash on PropertyGrid delete

 Post Reply Post Reply
Author
Message
Paolo View Drop Down
Newbie
Newbie


Joined: 02 March 2006
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Paolo Quote  Post ReplyReply Direct Link To This Post Topic: Crash on PropertyGrid delete
    Posted: 12 May 2006 at 4:58am
Hello everyone!

I created a PropertyGrid derived class with empty destructor.
When I delete an instance of this class,
CXTPPropertyGrid::~CXTPPropertyGrid()

is called: first instruction in this method is
delete m_pPaintManager;
which executes
CMDTARGET_RELEASE(m_pMetrics);
. This instruction substantially destroys m_pMetrics and resets it to NULL.
CXTPPropertyGrid::~CXTPPropertyGrid()
then goes on with:
if (m_pView) {
  delete m_pView;
}

that executes
CXTPPropertyGridView::ResetContent()
that contains the instruction
CFont* pFont =  &GetPaintManager()->GetItemMetrics()->m_fontNormal ;

PaintManager is still a valid object, but m_pMetrics in it is no more valid thus is not correct to access it to get
m_fontNormal


for this reason
pFont
is not assigned correctly and when
CXTPPropertyGridView::ResetContent()
executes the successive instruction
SetFont(pFont, FALSE);
makes the application to crash.

This is what I've been able to trace about my Application crash.
Now the question: am I someway wrong in deleting PropertyGrid or is this a bug that has been solved in latest release (I'm actually using 9.81 ToolkitPro).

Thanks for any help
Paolo
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 May 2006 at 6:53pm

Yes, it was already fixed...

Add

m_pView->DestroyWindow();
in destructor of  inherited class

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kisly View Drop Down
Newbie
Newbie


Joined: 19 May 2006
Location: Russian Federation
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kisly Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 8:09am

У нас те же косяки, только не в унаследованном Property Grid, а в dll, в которой есть модальный диалог с Property Grid'ом. В Debug-ной версии (мы купили 9.81). Падает при закрытии диалога. В exeшнике тот же диалог не падает.

Письмо написали.

Замена delete на DestroyWindow(); в прЫнцыпе помогает, но это же не наш метод. К тому же, достаточно ли этого? Вот и возникает извечный русский вопрос: что делать?

То есть, надо ли качать новую версию библиотеки и переставлять или как вообще этот баг поправить?

С уважением, Олег Пресняков, Рязань

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 9:55am

День добрый.

Нужно не заменить, а добавить перед delete... А лучше, конечно, поменять на 10.1.

Просто создайте класс наследованный от CXTPPropertyGrid и в деструкторе добавьте m_pView->DestroyWindow(); 

Должно помочь.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kisly View Drop Down
Newbie
Newbie


Joined: 19 May 2006
Location: Russian Federation
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kisly Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2006 at 10:02am

Здравствуйте!

Спасибо за оперативный ответ. Будем пробовать.

Back to Top
Kisly View Drop Down
Newbie
Newbie


Joined: 19 May 2006
Location: Russian Federation
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kisly Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2006 at 3:38am
Добавка m_pView->DestroyWindow() в деструктор унаследованного класса не помогает. Может есть какие-то особенности, когда компонент находится внутри dll?

Насчет новой версии: мы можем скачать toolkit только 4 раза (1 уже израсходован). Чем вызвано такое непонятное ограничение? Новые версии выходят достаточно часто, и получается, что мы не можем скачивать их все?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2006 at 8:29am

Здравствуйте,

1. Странно. Может есть возможность послать нам проект, что б мы его потестировали?

2. Это просто небольшая защита от постороннего скачивания.... Если счетчик обнуляется, напишите письмо на sales@codejock.com , вам его восстановят.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Kisly View Drop Down
Newbie
Newbie


Joined: 19 May 2006
Location: Russian Federation
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kisly Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2006 at 8:53am
Originally posted by oleg oleg wrote:

1. Странно. Может есть возможность послать нам проект, что б мы его потестировали?


Проблема решилась. Наша dll была скомпилирована с выравниванием по одному байту, а сам тулкит по 8. Тогда другой вопрос: если перекомпилировать сам тулкит с выравниванием по одному байту не вызовет ли это каких-либо проблем?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 06 June 2006 at 2:48pm

Не вижу проблем... Попробуйте. :)

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.