Pārlūkot izejas kodu

Merge pull request #940 from sabrogden/caret

Fixed crash when existing with delete clip data window open, use care…
sabrogden 1 mēnesi atpakaļ
vecāks
revīzija
6516d2d615
3 mainītis faili ar 17 papildinājumiem un 6 dzēšanām
  1. 4 4
      CP_Main.rc
  2. 5 1
      src/DeleteClipData.cpp
  3. 8 1
      src/MainFrm.cpp

+ 4 - 4
CP_Main.rc

@@ -1785,10 +1785,10 @@ IDD_OPTIONS_GENERAL DLGINIT
 BEGIN
     IDC_MFCLINK_ENV_VAR, 0x37c, 255, 0
 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x683e, 0x7474, 0x7370, 
-0x2f3a, 0x732f, 0x756f, 0x6372, 0x6665, 0x726f, 0x6567, 0x6e2e, 0x7465, 
-0x702f, 0x642f, 0x7469, 0x6f74, 0x632d, 0x2f70, 0x6977, 0x696b, 0x452f, 
-0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, 0x6156, 0x6972, 0x6261, 0x656c, 
-0x2f73, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x3e6c, 0x4d3c, 
+0x2f3a, 0x672f, 0x7469, 0x7568, 0x2e62, 0x6f63, 0x2f6d, 0x6173, 0x7262, 
+0x676f, 0x6564, 0x2f6e, 0x6944, 0x7474, 0x2f6f, 0x6977, 0x696b, 0x452f, 
+0x766e, 0x7269, 0x6e6f, 0x656d, 0x746e, 0x562d, 0x7261, 0x6169, 0x6c62, 
+0x7365, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x3e6c, 0x4d3c, 
 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 0x3c3e, 
 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 
 0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 0x3e70, 

+ 5 - 1
src/DeleteClipData.cpp

@@ -437,6 +437,8 @@ void CDeleteClipData::OnLvnItemchangedList2(NMHDR *pNMHDR, LRESULT *pResult)
 	int selectedCount = 0;
 	bool setDescriptionWindowText = false;
 
+	int nCaretItem = m_clipList.GetNextItem(-1, LVNI_FOCUSED);
+
 	if (pos != nullptr)
 	{
 		while (pos)
@@ -448,7 +450,8 @@ void CDeleteClipData::OnLvnItemchangedList2(NMHDR *pNMHDR, LRESULT *pResult)
 				selectedDataSize += m_data[row].m_dataSize;
 				selectedCount++;
 
-				if (setDescriptionWindowText == false &&
+				if (row == nCaretItem &&
+					setDescriptionWindowText == false &&
 					m_pDescriptionWindow != nullptr && 
 					m_pDescriptionWindow->IsWindowVisible())
 				{
@@ -934,6 +937,7 @@ void CDeleteClipData::SetDescriptionWindowText(INT_PTR row)
 {
 	m_pDescriptionWindow->SetGdiplusBitmap(NULL);
 	m_pDescriptionWindow->SetRTFText("");
+	m_pDescriptionWindow->SetHtmlText("");
 	m_pDescriptionWindow->SetToolTipText(_T(""));
 	m_pDescriptionWindow->SetFolderPath(_T(""));
 

+ 8 - 1
src/MainFrm.cpp

@@ -976,6 +976,8 @@ bool CMainFrame::CloseAllOpenDialogs()
     GetWindowThreadProcessId(this->m_hWnd, &dwordProcessId);
     ASSERT(dwordProcessId);
 
+	CArray<CWnd*, CWnd*> openDialogs;
+
     CWnd *pTempWnd = GetDesktopWindow()->GetWindow(GW_CHILD);
     while((pTempWnd = pTempWnd->GetWindow(GW_HWNDNEXT)) != NULL)
     {
@@ -993,12 +995,17 @@ bool CMainFrame::CloseAllOpenDialogs()
             // #32770 is class name for dialogs so don't process the message if it is a dialog
             if(STRCMP(szTemp, _T("#32770")) == 0)
             {
-                pTempWnd->SendMessage(WM_CLOSE, 0, 0);
+				openDialogs.Add(pTempWnd);                
                 bRet = true;
             }
         }
     }
 
+	for (int i = 0; i < openDialogs.GetCount(); i++)
+	{
+		openDialogs[i]->PostMessage(WM_CLOSE, 0, 0);
+	}
+
     MSG msg;
     while(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
     {