Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - [solved] FlowGraph Bug
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] FlowGraph Bug

 Post Reply Post Reply
Author
Message
cluster View Drop Down
Groupie
Groupie


Joined: 22 January 2015
Status: Offline
Points: 91
Post Options Post Options   Thanks (0) Thanks(0)   Quote cluster Quote  Post ReplyReply Direct Link To This Post Topic: [solved] FlowGraph Bug
    Posted: 15 November 2017 at 6:42am
Hello,

I figured out that CXTPFlowGraphConnection objects will not deleted if I block the "add" process.
So, if I return a *pResult = -1 in a XTP_FGN_CONNECTIONCHANGED NotifyMessage the connection will not deleted.
I triggered a ASSERT message in CXTPFlowGraphConnectionPoint::OnRemoved()

    // Removed Connections should update them
    ASSERT(m_arrInputConnections.GetSize() == 0);
    ASSERT(m_arrOutputConnections.GetSize() == 0);



Windows 7, Visual Studio 2010, Toolkit Pro 17.3.0
Windows 7
Visual Studio 2013
CodeJock 18.6
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2017 at 4:18pm
Hello cluster,

For preventing adding connection you should handle XTP_FGN_CONNECTIONCHANGING NotifyMessage which used during changing.
XTP_FGN_CONNECTIONCHANGED used after changes.

Regards,
 Oleksandr Lebed
Back to Top
cluster View Drop Down
Groupie
Groupie


Joined: 22 January 2015
Status: Offline
Points: 91
Post Options Post Options   Thanks (0) Thanks(0)   Quote cluster Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2017 at 6:44am
Hello Oleksandr,

thank for your reply.
The order of the messages is:
1. StartDragConnectionPoint (DragEnter) -> Create a Connection -> Send the XTP_FGN_CONNECTIONCHANGED message
2. WM_MOUSEMOVE (DragOver) -> Send the XTP_FGN_CONNECTIONCHANGING message
3. (Drop) -> there is no message anymore!

And I want to block the starting process, of course I could deviate from the control class, but I thought therefor there are these messages.
Windows 7
Visual Studio 2013
CodeJock 18.6
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2017 at 8:36pm
Hello cluster,

There is really sophisticated situation with these notifications. I think it is because creating connection is complex action.
First XTP_FGN_CONNECTIONCHANGED notification is about creation temporary Connection object pDragConnection (method CXTPFlowGraphControl::StartDragConnectionPoint), which will be deleted at the end of method if end point (InputPoint) is empty.

To allow your algorithm works (prevent even starting of creation new connection) and to correct handling canceling in notification we need to add handling "*pResult = -1" in StartDragConnectionPoint().
One of way is checking CXTPFlowGraphConnection::m_nConnectionIndex of new connection or other member CXTPFlowGraphConnection::m_pPage with public getter GetPage().
void CXTPFlowGraphControl::StartDragConnectionPoint(CXTPFlowGraphConnectionPoint* pPoint)
{
....
    CXTPFlowGraphConnection* pDragConnection = new CXTPFlowGraphConnection();
    pDragConnection->SetOutputPoint(pOutputPoint);

    m_pActivePage->GetConnections()->AddConnection(pDragConnection);

    //adding connection was canceled through notification
    if (pDragConnection->m_nConnectionIndex == -1 || pDragConnection->GetPage() == NULL)
    {
        pDragConnection->OnRemoved();
        pDragConnection->InternalRelease();
        return;
    }
....
Such conditions should be added in CXTPFlowGraphUndoDeleteConnectionCommand::Undo
void CXTPFlowGraphUndoDeleteConnectionCommand::Undo()
{
......
        m_pPage->GetConnections()->AddConnection(m_pConnection);
        
        //adding connection was canceled through notification
        if (m_pConnection->GetPage() == NULL)
        {
            m_pConnection->OnRemoved();
            m_pConnection->InternalRelease();
            return;
        }
    }
}

The reason of assertions in CXTPFlowGraphConnectionPoint::OnRemoved() is because you don't allow addition new connection in AddConnection() but then you call 
SetInputPoint() or SetOutputPoint()
    CXTPFlowGraphConnection* pConnection;
    pConnection = pPage->GetConnections()->AddConnection(new CXTPFlowGraphConnection());
    pConnection->SetOutputPoint(pTableOrders->GetConnectionPoints()->FindConnectionPoint(_T("Customer ID")));
    pConnection->SetInputPoint(pTableCustomers->GetConnectionPoints()->FindConnectionPoint(_T("ID")));
in such code should be added checking results of AddConnection()
    CXTPFlowGraphConnection* pConnection;
    pConnection = pPage->GetConnections()->AddConnection(new CXTPFlowGraphConnection());
    if (pConnection->GetPage() == NULL)    //adding connection was canceled through notification
    {
        //pConnection->OnRemoved();
        pConnection->InternalRelease();
        pConnection = NULL;
    }
    else
    {
        pConnection->SetOutputPoint(pTableOrders->GetConnectionPoints()->FindConnectionPoint(_T("Customer ID")));
        pConnection->SetInputPoint(pTableCustomers->GetConnectionPoints()->FindConnectionPoint(_T("ID")));
    }

Regards,
 Oleksandr Lebed
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.141 seconds.