Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r2d7bee54f998ae8f5d4145a2cf3f4a589253016f -r3d1951f52696fe21e01618e1bbfb9e14745a3827 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 2d7bee54f998ae8f5d4145a2cf3f4a589253016f) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 3d1951f52696fe21e01618e1bbfb9e14745a3827) @@ -462,57 +462,64 @@ BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { - // load task from buffer - wchar_t* pszBuffer = static_cast(pCopyDataStruct->lpData); - unsigned long ulLen = pCopyDataStruct->cbData / sizeof(wchar_t); + if(!pCopyDataStruct) + return CWnd::OnCopyData(pWnd, pCopyDataStruct); - // check if the string ends with '\0', so we can safely use it without length checks - if(!pszBuffer || ulLen == 0 || pszBuffer[ulLen - 1] != L'\0') - return FALSE; + switch(pCopyDataStruct->dwData) + { + case eCDType_TaskDefinitionContentSpecial: + case eCDType_TaskDefinitionContent: + { + // load task from buffer + wchar_t* pszBuffer = static_cast(pCopyDataStruct->lpData); + unsigned long ulLen = pCopyDataStruct->cbData / sizeof(wchar_t); - chcore::TWStringData wstrData(pszBuffer); - //AfxMessageBox(wstrData.GetData()); // TEMP = to remove before commit + // check if the string ends with '\0', so we can safely use it without length checks + if(!pszBuffer || ulLen == 0 || pszBuffer[ulLen - 1] != L'\0') + return FALSE; - chcore::TTaskDefinition tTaskDefinition; - tTaskDefinition.LoadFromString(wstrData); + chcore::TWStringData wstrData(pszBuffer); + //AfxMessageBox(wstrData.GetData()); // TEMP = to remove before commit - // apply current options from global config; in the future we might want to merge the incoming options with global ones instead of overwriting... - chcore::TConfig& rConfig = GetConfig(); - rConfig.ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); + chcore::TTaskDefinition tTaskDefinition; + tTaskDefinition.LoadFromString(wstrData); - // special operation - modify stuff - switch(pCopyDataStruct->dwData & CSharedConfigStruct::OPERATION_MASK) - { - case CSharedConfigStruct::DD_COPYMOVESPECIAL_FLAG: - case CSharedConfigStruct::EC_PASTESPECIAL_FLAG: - case CSharedConfigStruct::EC_COPYMOVETOSPECIAL_FLAG: - CCustomCopyDlg dlg(tTaskDefinition); + // apply current options from global config; in the future we might want to merge the incoming options with global ones instead of overwriting... + chcore::TConfig& rConfig = GetConfig(); + rConfig.ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); - GetPropValue(rConfig, dlg.m_vRecent); + // special operation - modify stuff + if(pCopyDataStruct->dwData == eCDType_TaskDefinitionContentSpecial) + { + CCustomCopyDlg dlg(tTaskDefinition); - INT_PTR iModalResult; - if((iModalResult = dlg.DoModal()) == IDCANCEL) - return CWnd::OnCopyData(pWnd, pCopyDataStruct); - else if(iModalResult == -1) // windows has been closed by a parent - return TRUE; + GetPropValue(rConfig, dlg.m_vRecent); - dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); + INT_PTR iModalResult; + if((iModalResult = dlg.DoModal()) == IDCANCEL) + return CWnd::OnCopyData(pWnd, pCopyDataStruct); + else if(iModalResult == -1) // windows has been closed by a parent + return TRUE; - SetPropValue(rConfig, dlg.m_vRecent); + dlg.m_vRecent.push_back(dlg.m_tTaskDefinition.GetDestinationPath().ToString()); - tTaskDefinition = dlg.m_tTaskDefinition; - } + SetPropValue(rConfig, dlg.m_vRecent); - // load resource strings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); + tTaskDefinition = dlg.m_tTaskDefinition; + } - // create task with the above definition - CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); + // load resource strings + SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); + SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); - // add to task list and start processing - spTask->BeginProcessing(); + // create task with the above definition + CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); + // add to task list and start processing + spTask->BeginProcessing(); + } + } + return CWnd::OnCopyData(pWnd, pCopyDataStruct); }