CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Threaded View

  1. #1
    Join Date
    May 2015
    Posts
    500

    Critical section begin end() changing the auto value

    Hello,

    In the following piece of code, used to work. Now i was debugging something else (in debug mode) and i see an issue:
    Code:
    const auto& sDecouplingId = ulDlDecoupcells.m_bIsMultiplePair ? "NR cell decoupled more than once" : cpTddCell->GetID();
    const auto& bEnableDecoupling = true;
    
    pTddCopyCellCarrier->SetDecouplingId(sDecouplingId);
    pTddCopyCellCarrier->SetDecouplingEnabled(bEnableDecoupling);
    
    EnterCriticalSection(&m_CriticalSectionDB);
    if (!BusinessObjects::BO_DBHelper::instance().Apply(pTddCopyCell.get(), pTddCopyCell.get()))
    {
            AI_Message::instance()->Add("Database Error. Failed to update cell: %s", pTddCopyCell->GetID());
    	LeaveCriticalSection(&m_CriticalSectionDB);
    	return;
    }
    LeaveCriticalSection(&m_CriticalSectionDB);
    
    pSulCopyCellCarrier->SetDecouplingId(sDecouplingId);
    pSulCopyCellCarrier->SetDecouplingEnabled(bEnableDecoupling);
    The local variable "sDecouplingId " is having some garbage value after the LeaveCriticalSection() function !!!.

    As it is release is closing, i found a shortcut and found and did the following change to it work
    Code:
    pSulCopyCellCarrier->SetDecouplingId(pTddCopyCellCarrier->GetDecouplingId());
    pSulCopyCellCarrier->SetDecouplingEnabled(bEnableDecoupling);
    I want to know, why the earlier code started to behave like that ?
    I have not run in Release mode . Is it because of the debug mode ?

    thanks
    Pdk
    Last edited by 2kaud; August 13th, 2020 at 02:19 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured