Browse Source

Fixed gdi leaks

scott brogden 5 years ago
parent
commit
bd4f6d82e5
5 changed files with 20 additions and 10 deletions
  1. 4 4
      DittoWindow.cpp
  2. 9 3
      QPasteWnd.cpp
  3. 5 1
      QPasteWndThread.cpp
  4. 1 1
      QRCodeViewer.cpp
  5. 1 1
      ToolTipEx.cpp

+ 4 - 4
DittoWindow.cpp

@@ -716,12 +716,12 @@ void CDittoWindow::SetCaptionOn(CWnd *pWnd, int nPos, bool bOnstartup, int capti
 {
 	m_captionFontSize = captionFontSize;
 
-	m_VertFont.Detach();
+	m_VertFont.DeleteObject();
 	m_VertFont.CreateFont(-m_dpi.Scale(captionFontSize), 0, -900, 0, 400, FALSE, FALSE, 0, DEFAULT_CHARSET,
 		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
 		DEFAULT_PITCH | FF_SWISS, _T("Segoe UI"));
 
-	m_HorFont.Detach();
+	m_HorFont.DeleteObject();
 	m_HorFont.CreateFont(-m_dpi.Scale(captionFontSize), 0, 0, 0, 500, FALSE, FALSE, 0, DEFAULT_CHARSET,
 		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
 		DEFAULT_PITCH | FF_SWISS, _T("Segoe UI"));
@@ -887,8 +887,8 @@ void CDittoWindow::OnDpiChanged(CWnd *pParent, int dpi)
 	m_captionBorderWidth = m_dpi.Scale(25);
 	m_borderSize = m_dpi.Scale(2);
 
-	m_VertFont.Detach();
-	m_HorFont.Detach();
+	m_VertFont.DeleteObject();
+	m_HorFont.DeleteObject();
 
 	m_VertFont.CreateFont(-m_dpi.Scale(m_captionFontSize), 0, -900, 0, 400, FALSE, FALSE, 0, DEFAULT_CHARSET,
 		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,

+ 9 - 3
QPasteWnd.cpp

@@ -2000,14 +2000,14 @@ void CQPasteWnd::UpdateFont()
 	lf.lfHeight = m_DittoWindow.m_dpi.Scale(lf.lfHeight);
 	m_lstHeader.SetLogFont(lf);
 
-	m_SearchFont.Detach();
+	m_SearchFont.DeleteObject();
 	m_SearchFont.CreateFont(-m_DittoWindow.m_dpi.Scale(15), 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, 34, _T("Segoe UI"));
 	m_search.SetFont(&m_SearchFont);
 	m_search.SetPromptFont(m_SearchFont);
 
 	m_GroupTree.SetFont(&m_SearchFont);
 
-	m_groupFont.Detach();
+	m_groupFont.DeleteObject();
 	m_groupFont.CreateFont(-m_DittoWindow.m_dpi.Scale(12), 0, 0, 0, 400, 0, 1, 0, DEFAULT_CHARSET, 3, 2, 1, 34, _T("Segoe UI"));
 	m_stGroup.SetFont(&m_groupFont);
 	m_stGroup.SetBkColor(g_Opt.m_Theme.MainWindowBG());
@@ -5098,9 +5098,15 @@ void CQPasteWnd::OnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
 	this->SetTimer(TIMER_DRAG_HIDE_WINDOW, 500, NULL);
 
 	paste.DoDrag();
-
+	
 	KillTimer(TIMER_DRAG_HIDE_WINDOW);
 
+
+	if (g_Opt.m_bShowPersistent)
+	{
+		ShowQPasteWindow(0);
+	}
+
 	*pResult = 0;
 }
 

+ 5 - 1
QPasteWndThread.cpp

@@ -371,7 +371,11 @@ void CQPasteWndThread::OnLoadExtraData(void *param)
 				{
 					DWORD startConvertImage = GetTickCount();
 
-					it->GetDibFittingToHeight(CDC::FromHandle(GetDC(NULL)), m_rowHeight);
+					HDC dc = GetDC(NULL);
+
+					it->GetDibFittingToHeight(CDC::FromHandle(dc), m_rowHeight);
+
+					ReleaseDC(NULL, dc);
 
 					DWORD timeTook = GetTickCount() - startConvertImage;
 					if (timeTook > 20)

+ 1 - 1
QRCodeViewer.cpp

@@ -300,7 +300,7 @@ LRESULT QRCodeViewer::OnDpiChanged(WPARAM wParam, LPARAM lParam)
 
 	m_logFont.lfHeight = m_DittoWindow.m_dpi.Scale(m_originalFontHeight);
 
-	m_font.Detach();
+	m_font.DeleteObject();
 	m_font.CreateFontIndirect(&m_logFont);
 	m_desc.SetFont(&m_font);
 

+ 1 - 1
ToolTipEx.cpp

@@ -1392,7 +1392,7 @@ LRESULT CToolTipEx::OnDpiChanged(WPARAM wParam, LPARAM lParam)
 	m_optionsButton.Reset();
 	m_optionsButton.LoadStdImageDPI(m_DittoWindow.m_dpi.GetDPI(), IDB_COG_16_16, IDB_COG_20_20, IDB_COG_24_24, cog_28, IDB_COG_32_32, _T("PNG"));
 
-	m_clipDataFont.Detach();
+	m_clipDataFont.DeleteObject();
 	m_clipDataFont.CreateFont(-m_DittoWindow.m_dpi.Scale(8), 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, 34, _T("Segoe UI"));
 	
 	m_clipDataStatic.SetFont(&m_clipDataFont);