Print Page | Close Window

[solved] FlowGraph Bug

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=23488
Printed Date: 29 April 2024 at 2:04am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] FlowGraph Bug
Posted By: cluster
Subject: [solved] FlowGraph Bug
Date 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



Replies:
Posted By: olebed
Date 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


Posted By: cluster
Date 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


Posted By: olebed
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net