CAD collapse while closing if I create a CDocument in CAD winFrame

CAD collapse while closing if I create a CDocument in CAD winFrame

27925916
Advocate Advocate
865 Views
4 Replies
Message 1 of 5

CAD collapse while closing if I create a CDocument in CAD winFrame

27925916
Advocate
Advocate

I create a CDocument attached a dialog in CAD winFrame,and switch this document with other dwg drawings,for example, there are two dwg and one CDOcument create by mine,when I switch from A.dwg to B.dwg, which trigger the function AcApDocManagerReactor::documentActivated() in that I use code "CView* pViewA = acedGetAcadDwgView();" ,and when I use code "(CMDIFrameWnd*)(acedGetAcadFrame())->MDIActivate(pWndAttachMyCDocument)"to switch from B.dwg to my CDocument, AcApDocManagerReactor::documentToBeDeactivated is triggerred but AcApDocManagerReactor::documentActivated() isn't triggerred. and  at last, I use code "acDocManagerPtr()->activateDocument(A.dwg)"switch from my CDocument to A.dwg, which trigger the function AcApDocManagerReactor::documentActivated()  and in that function the CView returned by  acedGetAcadDwgView()  is CView of A.dwg , at last ,if I click close button of CAD to exit , the AcApDocManagerReactor::documentDestroyed(const ACHAR* fileName) is triggerred and fileName is A.dwg, but cad breakdown after this function finished。

 

The breakdown order is:

A.dwg ->B.dwg->my CDocument attached a dialog ->A.dwg->close CAD->AcApDocManagerReactor::documentDestroyed(A.dwg's filename) ->breakdown

 

Crash stack

tt.png

 

However,it close successfully if the order is like below:

A.dwg ->B.dwg->my CDocument attached a dialog ->A.dwg->->B.dwg->close CAD->AcApDocManagerReactor::documentDestroyed(B.dwg's filename) ->->AcApDocManagerReactor::documentDestroyed(A.dwg's filename)->close successfully.

it seems that my cdocument disturbs the cview of dwg to close?

 

866 Views
4 Replies
Replies (4)
Message 2 of 5

tbrammer
Advisor
Advisor

It is hard to tell what leads to the crash without source code that shows what your AcApDocManagerReactor is doing. Have you tried to simply disable your AcApDocManagerReactor as soon an AutoCAD ends?

Try to do this within AcEditorReactor::commandWillStart(L"QUIT").

 

This is the order of events I see in AutoCAD 2020 upon QUIT:

  • AcEditorReactor::commandWillStart('QUIT')
  • AcEditorReactor::commandEnded('QUIT')
  • AcApDocManagerReactor::documentToBeDestroyed(Drawing1.dwg)
  • ::acrxEntryPoint(AcRx::kUnloadDwgMsg)
  • AcApDocManagerReactor::documentDestroyed(Drawing1.dwg)
  • ::acrxEntryPoint(AcRx::kQuitMsg)

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 5

27925916
Advocate
Advocate
"acDocManagerPtr()->removeReactor(AcApDocManagerReactor) "in commandWillStart("quit") or commandWillStart ("quit") will crash down
0 Likes
Message 4 of 5

tbrammer
Advisor
Advisor

Can you try to "disable" your reactor in commandWillStart("quit") instead of removing it?

I.e. like this:

class MyAcApDocManagerReactor: public AcApDocManagerReactor {
  public:
     void setDisabled(bool disabled) { m_ReactorDisabled = disabled; }
  private:
     bool m_ReactorDisabled=false;
}

void MyAcApDocManagerReactor::documentToBeDestroyed(AcApDocument* pDocToDestroy)
{
   if (m_ReactorDisabled)
       return;
   // your code
}

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 5 of 5

27925916
Advocate
Advocate

the reason seems to be the conflict between the view of dwg and  the CDocument created by myself, so I have a try to delete  the view of CDocuement created by myself in CommandWllStart(Quit) , which solve the crash problem😀  thanks anyway

0 Likes