Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor: Stop XAB crashing when pressing Modify/Delete
[xestiaab/.git] / source / contacteditor / frmContactEditor-Calendar.cpp
index 8813635..083dc80 100644 (file)
@@ -1,6 +1,6 @@
 // frmContactEditor-Calendar.cpp - frmContactEditor Calendar tab subroutines.
 //
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2016 Xestia Software Development.
 //
 // This file is part of Xestia Address Book.
 //
 
 void frmContactEditor::AddCalendarAddress( wxCommandEvent& event )
 {
-    int intResult = 0;
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetEditorMode(FALSE);
-    intResult = GetLastInt(&ContactEditorData.CalendarList);
-    frameCECalAdr->SetupPointers(&ContactEditorData.CalendarList,
-                                 &ContactEditorData.CalendarListAltID,
-                                 &ContactEditorData.CalendarListPID,
-                                 &ContactEditorData.CalendarListType,
-                                 &ContactEditorData.CalendarListTokens,
-                                 &ContactEditorData.CalendarListPref,
-                                 lboCalendarAddresses,
-                                 (intValueSeek));
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to add the calendar address.
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetEditorMode(FALSE);
+       frameCECalAdr->SetupPointers(&ContactEditorData.CalendarList,
+               &ContactEditorData.CalendarListAltID,
+               &ContactEditorData.CalendarListPID,
+               &ContactEditorData.CalendarListType,
+               &ContactEditorData.CalendarListTokens,
+               &ContactEditorData.CalendarListPref,
+               lboCalendarAddresses,
+               (intValueSeek));
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::ModifyCalendarAddress( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
-    
-    if (!GetSelectedItem(lboCalendarAddresses,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetupPointers(&ContactEditorData.CalendarList,
-                                 &ContactEditorData.CalendarListAltID,
-                                 &ContactEditorData.CalendarListPID,
-                                 &ContactEditorData.CalendarListType,
-                                 &ContactEditorData.CalendarListTokens,
-                                 &ContactEditorData.CalendarListPref,
-                                 lboCalendarAddresses,
-                                 intSelectedData);
-    frameCECalAdr->SetEditorMode(TRUE);
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to modify the calendar address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (lboCalendarAddresses->GetItemCount() == 0 || !GetSelectedItem(lboCalendarAddresses,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetupPointers(&ContactEditorData.CalendarList,
+               &ContactEditorData.CalendarListAltID,
+               &ContactEditorData.CalendarListPID,
+               &ContactEditorData.CalendarListType,
+               &ContactEditorData.CalendarListTokens,
+               &ContactEditorData.CalendarListPref,
+               lboCalendarAddresses,
+               intSelectedData);
+       frameCECalAdr->SetEditorMode(TRUE);
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::DeleteCalendarAddress( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
+
+       // Bring up the window to delete the calendar address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
     
-    if (!GetSelectedItem(lboCalendarAddresses,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
+       if (lboCalendarAddresses->GetItemCount() == 0 || !GetSelectedItem(lboCalendarAddresses,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
     
-    lboCalendarAddresses->DeleteItem(longSelected);
+       lboCalendarAddresses->DeleteItem(longSelected);
     
-    DeleteMapData(intSelectedData, &ContactEditorData.CalendarList, &ContactEditorData.CalendarListAltID,
-                  &ContactEditorData.CalendarListPID, &ContactEditorData.CalendarListType, &ContactEditorData.CalendarListTokens,
-                  &ContactEditorData.CalendarListPref);
+       DeleteMapData(intSelectedData, &ContactEditorData.CalendarList, &ContactEditorData.CalendarListAltID,
+               &ContactEditorData.CalendarListPID, &ContactEditorData.CalendarListType, &ContactEditorData.CalendarListTokens,
+               &ContactEditorData.CalendarListPref);
     
 }
 
 void frmContactEditor::AddCalendarRequest( wxCommandEvent& event )
 {
-    int intResult = 0;
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetEditorMode(FALSE);
-    intResult = GetLastInt(&ContactEditorData.CalendarRequestList);
-    frameCECalAdr->SetupPointers(&ContactEditorData.CalendarRequestList,
-                                 &ContactEditorData.CalendarRequestListAltID,
-                                 &ContactEditorData.CalendarRequestListPID,
-                                 &ContactEditorData.CalendarRequestListType,
-                                 &ContactEditorData.CalendarRequestListTokens,
-                                 &ContactEditorData.CalendarRequestListPref,
-                                 lboCalendarRequestAddress,
-                                 (intValueSeek));
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to add a calendar request address.
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetEditorMode(FALSE);
+       frameCECalAdr->SetupPointers(&ContactEditorData.CalendarRequestList,
+               &ContactEditorData.CalendarRequestListAltID,
+               &ContactEditorData.CalendarRequestListPID,
+               &ContactEditorData.CalendarRequestListType,
+               &ContactEditorData.CalendarRequestListTokens,
+               &ContactEditorData.CalendarRequestListPref,
+               lboCalendarRequestAddress,
+               (intValueSeek));
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::ModifyCalendarRequest( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
-    
-    if (!GetSelectedItem(lboCalendarRequestAddress,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetupPointers(&ContactEditorData.CalendarRequestList,
-                                 &ContactEditorData.CalendarRequestListAltID,
-                                 &ContactEditorData.CalendarRequestListPID,
-                                 &ContactEditorData.CalendarRequestListType,
-                                 &ContactEditorData.CalendarRequestListTokens,
-                                 &ContactEditorData.CalendarRequestListPref,
-                                 lboCalendarRequestAddress,
-                                 intSelectedData);
-    frameCECalAdr->SetEditorMode(TRUE);
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to modify a calendar request address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (lboCalendarRequestAddress->GetItemCount() == 0 || !GetSelectedItem(lboCalendarRequestAddress,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetupPointers(&ContactEditorData.CalendarRequestList,
+               &ContactEditorData.CalendarRequestListAltID,
+               &ContactEditorData.CalendarRequestListPID,
+               &ContactEditorData.CalendarRequestListType,
+               &ContactEditorData.CalendarRequestListTokens,
+               &ContactEditorData.CalendarRequestListPref,
+               lboCalendarRequestAddress,
+               intSelectedData);
+       frameCECalAdr->SetEditorMode(TRUE);
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::DeleteCalendarRequest( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
-    
-    if (!GetSelectedItem(lboCalendarRequestAddress,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
-    
-    lboCalendarRequestAddress->DeleteItem(longSelected);
-    
-    DeleteMapData(intSelectedData, &ContactEditorData.CalendarRequestList,
-                  &ContactEditorData.CalendarRequestListAltID, &ContactEditorData.CalendarRequestListPID,
-                  &ContactEditorData.CalendarRequestListType, &ContactEditorData.CalendarRequestListTokens,
-                  &ContactEditorData.CalendarRequestListPref);
+
+       // Bring up the window to delete a calendar request address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (lboCalendarRequestAddress->GetItemCount() == 0 || !GetSelectedItem(lboCalendarRequestAddress,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
+    
+       lboCalendarRequestAddress->DeleteItem(longSelected);
+    
+       DeleteMapData(intSelectedData, &ContactEditorData.CalendarRequestList,
+               &ContactEditorData.CalendarRequestListAltID, &ContactEditorData.CalendarRequestListPID,
+               &ContactEditorData.CalendarRequestListType, &ContactEditorData.CalendarRequestListTokens,
+               &ContactEditorData.CalendarRequestListPref);
+               
 }
 
 void frmContactEditor::AddFreeBusy( wxCommandEvent& event )
 {
-    int intResult = 0;
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetEditorMode(FALSE);
-    intResult = GetLastInt(&ContactEditorData.FreeBusyList);
-    frameCECalAdr->SetupPointers(&ContactEditorData.FreeBusyList,
-                                 &ContactEditorData.FreeBusyListAltID,
-                                 &ContactEditorData.FreeBusyListPID,
-                                 &ContactEditorData.FreeBusyListType,
-                                 &ContactEditorData.FreeBusyListTokens,
-                                 &ContactEditorData.FreeBusyListPref,
-                                 lboFreeBusyAddresses,
-                                 (intValueSeek));
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to add a calendar free/busy address.
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetEditorMode(FALSE);
+       frameCECalAdr->SetupPointers(&ContactEditorData.FreeBusyList,
+               &ContactEditorData.FreeBusyListAltID,
+               &ContactEditorData.FreeBusyListPID,
+               &ContactEditorData.FreeBusyListType,
+               &ContactEditorData.FreeBusyListTokens,
+               &ContactEditorData.FreeBusyListPref,
+               lboFreeBusyAddresses,
+               (intValueSeek));
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::ModifyFreeBusy( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
-    
-    if (!GetSelectedItem(lboFreeBusyAddresses,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
-    
-    frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
-    frameCECalAdr->SetupPointers(&ContactEditorData.FreeBusyList,
-                                 &ContactEditorData.FreeBusyListAltID,
-                                 &ContactEditorData.FreeBusyListPID,
-                                 &ContactEditorData.FreeBusyListType,
-                                 &ContactEditorData.FreeBusyListTokens,
-                                 &ContactEditorData.FreeBusyListPref,
-                                 lboFreeBusyAddresses,
-                                 intSelectedData);
-    frameCECalAdr->SetEditorMode(TRUE);
-    frameCECalAdr->ShowModal();
-    delete frameCECalAdr;
-    frameCECalAdr = NULL;
+
+       // Bring up the window to modify a calendar free/busy address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (lboFreeBusyAddresses->GetItemCount() == 0 || !GetSelectedItem(lboFreeBusyAddresses,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
+    
+       frmContactEditorCalAdr *frameCECalAdr = new frmContactEditorCalAdr ( this );
+       frameCECalAdr->SetupPointers(&ContactEditorData.FreeBusyList,
+               &ContactEditorData.FreeBusyListAltID,
+               &ContactEditorData.FreeBusyListPID,
+               &ContactEditorData.FreeBusyListType,
+               &ContactEditorData.FreeBusyListTokens,
+               &ContactEditorData.FreeBusyListPref,
+               lboFreeBusyAddresses,
+               intSelectedData);
+       frameCECalAdr->SetEditorMode(TRUE);
+       frameCECalAdr->ShowModal();
+       delete frameCECalAdr;
+       frameCECalAdr = NULL;
+       
 }
 
 void frmContactEditor::DeleteFreeBusy( wxCommandEvent& event )
 {
-    long longSelected = -1;
-    int intSelectedData = 0;
-    
-    if (!GetSelectedItem(lboFreeBusyAddresses,
-                         &longSelected,
-                         &intSelectedData)){
-        return;
-    }
-    
-    lboFreeBusyAddresses->DeleteItem(longSelected);
-    
-    DeleteMapData(intSelectedData, &ContactEditorData.FreeBusyList, &ContactEditorData.FreeBusyListAltID,
-                  &ContactEditorData.FreeBusyListPID, &ContactEditorData.FreeBusyListType, &ContactEditorData.FreeBusyListTokens,
-                  &ContactEditorData.FreeBusyListPref);
+
+       // Bring up the window to delete a calendar free/busy address.
+
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (lboFreeBusyAddresses->GetItemCount() == 0 || !GetSelectedItem(lboFreeBusyAddresses,
+               &longSelected,
+               &intSelectedData)){
+               
+               return;
+               
+       }
+    
+       lboFreeBusyAddresses->DeleteItem(longSelected);
+    
+       DeleteMapData(intSelectedData, &ContactEditorData.FreeBusyList, &ContactEditorData.FreeBusyListAltID,
+               &ContactEditorData.FreeBusyListPID, &ContactEditorData.FreeBusyListType, &ContactEditorData.FreeBusyListTokens,
+               &ContactEditorData.FreeBusyListPref);
     
 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy