Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Exception when deleting appointments in weekview
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Exception when deleting appointments in weekview

 Post Reply Post Reply
Author
Message
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Topic: Exception when deleting appointments in weekview
    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
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: 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
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post 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!

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: 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.
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post 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.


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: 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
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.