Print Page | Close Window

Exception when deleting appointments in weekview

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=23299
Printed Date: 30 March 2020 at 8:26am


Topic: Exception when deleting appointments in weekview
Posted By: Alex H.
Subject: Exception when deleting appointments in weekview
Date Posted: 29 March 2017 at 9:05am


It happens in weekview when deleting by keyboard using command (DEL) from various days (ony by one).

XTP 17.3 (MFC) with VS2015



Replies:
Posted By: olebed
Date Posted: 29 March 2017 at 1:05pm
Hello Alex,

I can't reproduce this.
Can you reproduce this in our CalendarDemo sample ?
Add GIF of reproducing, screenshot of used options (Options dialog).

Regards,
 Oleksandr Lebed


Posted By: Alex H.
Date Posted: 30 March 2017 at 3:18am
Hello Oleksandr,
I can't reproduce it with the Calendar Demo.
We use a cutom data provider in our sample. But the problem seems to be on a higher level.
Can you give use some information how that can happen?

Here is how we add Events:

//--------------------------------------------------------------------------------------- 
void CUICJCalendarView::OnRetrieveDayEvents(XTP_NOTIFY_CODE /*Event*/WPARAM wParam , LPARAM lParam)
//--------------------------------------------------------------------------------------- 
{		
	XTP_DATE_VALUE oDate = (XTP_DATE_VALUEwParam;
	CXTPCalendarEventsPtr* pEvents = (CXTPCalendarEventsPtr*) lParam// [in/out] A pointer to pointer to events array
	COleDateTime dtStart = (DATE)oDate;
 
	XTRACE(+1, _T("CUICJCalendarView::OnRetrieveDayEvents( für %s )"), (LPCTSTR) dtStart.Format((UINT)IDS_DATEFMT_DDMMYYYYA));
	
	int nDayCount = GetCalendarCtrl().GetActiveView()->GetViewDayCount();
	COleDateTime dtCurrentViewStart = GetCalendarCtrl().GetActiveView()->GetViewDayDate(0);
	XTRACE(0, _T(" nDayCount = %d  and first date  (%s) "), nDayCount, (LPCTSTR) dtCurrentViewStart.Format((UINT)IDS_DATEFMT_DDMMYYYYA));
 
	if(*pEvents == NULL)
	{
		*pEvents = new CXTPCalendarEvents();
		(*pEvents)->InternalAddRef();
	}
	else
	{
		(*pEvents)->RemoveAll();
		(*pEvents)->InternalAddRef();
 
		ASSERT((*pEvents)->GetCount() == 0);
	}
	
	CWaitCursor oWait;	
 
	// fill events to my own cache (not the calendar cache)
	if(dtStart == dtCurrentViewStart && nDayCount > 1)
		AssignEventsToTmpCache(dtCurrentViewStart, nDayCount);
 
	CXTPCalendarEvents* pEventsOfDayFromCache = NULL;	
	int					nDBIDate = CMfxDateTime(dtStart).GetDBIDate();
	if(m_oMapTmpEvents.Lookup(nDBIDate, pEventsOfDayFromCache))
	{
		XTRACE(0, _T("OnRetrieveDayEvents Count = %d"), pEventsOfDayFromCache->GetCount());		
		// get value from my cache
		(*pEvents)->Append(pEventsOfDayFromCache);
		(*pEvents)->CloneEvents();
		XTRACE(0, _T("OnRetrieveDayEvents Count = %d"), (*pEvents)->GetCount());
	}
	else
	{	
		// get the events by query
		AssignEvents((*pEvents), dtStart);
	}
	
	(*pEvents)->InternalRelease();
		
	XTRACE(-1, _T("<<CUICJCalendarView::OnRetrieveDayEvents"));
}

//--------------------------------------------------------------------------------------- BOOL CUICJCalendarView::AssignEvents(CXTPCalendarEventspEventsconst COleDateTime dtDate) //--------------------------------------------------------------------------------------- { XTRACE(+1, _T("CUICJCalendarView::AssignEvents(...,%s)"), (LPCTSTRCMfxDateTime(dtDate).Format((UINT)IDS_DATEFMT_DDMMYYYYA)); ASSERT(pEvents); ASSERT(m_poBLTMManager && m_pUITMFrame); ASSERT(m_poBLTMManager->GetOptions()); long                nDBIDate = CMfxDateTime(dtDate).GetDBIDate();        int                 nCount = 1;      CBLTMAppointData    oDlgData;    XTRACE(0, _T("CUICJCalendarView::AssignEvents Series -------")); for(int i = 0; i < nCount; ++i) { XTRACE(0, _T("GetDateEntryCount = %d"), m_pUITMFrame->GetDateEntryCount(nDBIDate + i)); for(POSITION Pos = m_pUITMFrame->GetFirstDatePosition(nDBIDate + i) ; Pos != NULL; ) { if(m_pUITMFrame->GetNextDate(Pos, nDBIDate + i, oDlgData, CBLTMManager::TM_DATADETAIL_RECPAT | CBLTMManager::TM_DATADETAIL_ATTENDEES)) { CXTPCalendarEvent* ptrEvent = new CXTPCalendarEvent(GetCalendarCtrl().GetDataProvider()); AssignEvent(ptrEvent, oDlgData, dtDate); pEvents->Add(ptrEvent); ptrEvent->InternalRelease(); } } } XTRACE(0, _T("CUICJCalendarView::AssignEvents single day appontments -------")); // Single Day Appointments CXDAVariantList oLstID; CDADateTime oFromSpan(UIMfx2DADateTime(CMfxDateTime(nDBIDate, 0))); CDADateTime oToSpan(UIMfx2DADateTime(CMfxDateTime((long)(nDBIDate+nCount-1), (long)MAX_TM_MINUTES))); if(m_poBLTMManager->GetListSingleDayAppointments(oLstID, oFromSpan, oToSpan)) { for(CXDAVariantList::const_iterator iterApp = oLstID.begin() ; iterApp != oLstID.end() ; ++iterApp) { CBLTMAppointData oTmpData; if(m_poBLTMManager->ReadAppointment(*iterApp, oTmpData, CBLTMManager::TM_DATADETAIL_RECPAT | CBLTMManager::TM_DATADETAIL_ATTENDEES)) { CXTPCalendarEvent* ptrEvent = new CXTPCalendarEvent(GetCalendarCtrl().GetDataProvider()); AssignEvent(ptrEvent, oTmpData, dtDate); pEvents->Add(ptrEvent); ptrEvent->InternalRelease(); } } } XTRACE(0, _T("CUICJCalendarView::AssignEvents Count = %d"), pEvents->GetCount()); XTRACE(-1, _T("<<CUICJCalendarView::AssignEvents")); return TRUE; } Thank you!



Posted By: olebed
Date Posted: 30 March 2017 at 3:26am
As I can see from  your callstack that CXTPCalendarViewGroup::m_pViewDay was initialized with wrong value 0xdddddddd.

It is initialized only in constructor
CXTPCalendarViewGroup::CXTPCalendarViewGroup(CXTPCalendarViewDay* pViewDay)
{
    m_pViewDay = pViewDay;
....

So you can set breakpoint here with condition  "pViewDay == 0xdddddddd"  and see what do such initialization.


Posted By: Alex H.
Date Posted: 30 March 2017 at 10:56am
Thank you!

Unfortunately it soes not hit that breakpoint.
What if the pointer is deleted after it was assigned (missing AddRef and Release) ?

This is the Watch of m_pViewGroup. Is looks valid except m_pResources and m_pViewDay.




Posted By: olebed
Date Posted: 31 March 2017 at 10:43am
no, m_pViewGroup poiner also invalid.

may be problem in CXTPCalendarViewEventT::GetViewGroup_()   (called from CXTPCalendarViewEvent::IsSelected() )

So check pointer  pViewEvent->m_pViewGroup  in CXTPCalendarView::OnKeyDown() in line 968



Print Page | Close Window