From da985f982d63b06db8784199105f73bc0a4d6fc6 Mon Sep 17 00:00:00 2001
From: Tobias Weimer <wishmaster51@googlemail.com>
Date: Wed, 15 Apr 2015 19:45:07 +0000
Subject: MirandaG15: - minor bugfixes

git-svn-id: http://svn.miranda-ng.org/main/trunk@12843 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 plugins/MirandaG15/src/CAppletManager.cpp                     |  7 ++++---
 plugins/MirandaG15/src/CChatScreen.cpp                        |  9 +++++++--
 plugins/MirandaG15/src/CConfig.cpp                            |  3 +--
 .../MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp    |  6 +++---
 plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp               |  2 +-
 plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp             | 11 ++++++-----
 plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp             |  4 ++--
 plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp           |  2 +-
 plugins/MirandaG15/src/LCDFramework/misc.cpp                  |  2 +-
 9 files changed, 26 insertions(+), 20 deletions(-)

(limited to 'plugins/MirandaG15')

diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp
index dbc34fd1c3..4596306b56 100644
--- a/plugins/MirandaG15/src/CAppletManager.cpp
+++ b/plugins/MirandaG15/src/CAppletManager.cpp
@@ -1205,9 +1205,10 @@ int CAppletManager::HookChatInbound(WPARAM wParam,LPARAM lParam)
 	GCEVENT *gce = (GCEVENT*)lParam;
 	GCDEST *gcd;
 	
-	if (gce == NULL || gce->pDest == NULL)
+	if (gce == NULL || (gcd = gce->pDest) == NULL) {
 		TRACE(_T("<< [%s] skipping invalid event\n"));
-	gcd = (GCDEST*)gce->pDest;
+		return 0;
+	}
 
 	TRACE(_T("<< [%s:%s] event %04X\n"),toTstring(gcd->pszModule).c_str(), gcd->ptszID, gcd->iType);
 	
@@ -1484,7 +1485,7 @@ int CAppletManager::HookChatInbound(WPARAM wParam,LPARAM lParam)
 	if(pHistory)
 	{
 		tstring strChannel = pHistory->strChannel;
-		if(CConfig::GetBoolSetting(NOTIFY_CHANNELCUTOFF) && strNick.length() > CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) {
+		if(CConfig::GetBoolSetting(NOTIFY_CHANNELCUTOFF) && strChannel.length() > CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) {
 			strChannel = strChannel.erase(CConfig::GetIntSetting(NOTIFY_CHANNELCUTOFF_OFFSET)) + _T("...");
 		}
 		Event.strDescription = strChannel + _T(" - ")+Event.strValue;
diff --git a/plugins/MirandaG15/src/CChatScreen.cpp b/plugins/MirandaG15/src/CChatScreen.cpp
index 34a82de04f..b4cc5b8a6d 100644
--- a/plugins/MirandaG15/src/CChatScreen.cpp
+++ b/plugins/MirandaG15/src/CChatScreen.cpp
@@ -714,10 +714,15 @@ void CChatScreen::OnLCDButtonDown(int iButton)
 			DeactivateMessageMode();
 		} else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
 			ActivateMessageMode();
-		} else if(iButton == LGLCDBUTTON_CANCEL) {
+		}
+/*
+		// Dead code
+		 else if(iButton == LGLCDBUTTON_CANCEL) {
 			DeactivateMessageMode();
 			CAppletManager::GetInstance()->ActivatePreviousScreen();
-		} else if(iButton == LGLCDBUTTON_MENU) {
+		}
+*/
+		else if(iButton == LGLCDBUTTON_MENU) {
 			DeactivateMessageMode();
 			CAppletManager::GetInstance()->ActivateEventScreen();
 		}
diff --git a/plugins/MirandaG15/src/CConfig.cpp b/plugins/MirandaG15/src/CConfig.cpp
index 70b40b89ba..6309483209 100644
--- a/plugins/MirandaG15/src/CConfig.cpp
+++ b/plugins/MirandaG15/src/CConfig.cpp
@@ -27,8 +27,7 @@ void CConfig::Initialize()
 
 void CConfig::Shutdown()
 {
-	if(m_hSampleFont)
-		DeleteObject(m_hSampleFont);
+	DeleteObject(m_hSampleFont);
 	UnhookEvent(m_hOptionsInitHook);
 }
 
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp
index 466b9cfe59..870d1d9009 100644
--- a/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/CLCDConnectionLogitech.cpp
@@ -922,7 +922,7 @@ SG15LightStatus CLCDConnectionLogitech::GetLightStatus()
 	// MRKey
 	status.bMRKey = !(data[3] & G15_MR_LIGHT);
 
-	free(data);
+	delete[] data;
 
 	return status;
 }
@@ -950,7 +950,7 @@ void CLCDConnectionLogitech::SetMKeyLight(bool bM1,bool bM2,bool bM3,bool bMR)
 	data[3] = 0x00; 
 
 	HidD_SetFeature(m_hHIDDeviceHandle, data, m_HIDCapabilities.FeatureReportByteLength); 
-	free(data);
+	delete[] data;
 }
 
 void CLCDConnectionLogitech::SetLCDBacklight(ELCDBrightness eBrightness)
@@ -968,7 +968,7 @@ void CLCDConnectionLogitech::SetLCDBacklight(ELCDBrightness eBrightness)
 
 	HidD_SetFeature(m_hHIDDeviceHandle, data, m_HIDCapabilities.FeatureReportByteLength); 
 
-	free(data);
+	delete[] data;
 }
 
 void CLCDConnectionLogitech::SetKBDBacklight(EKBDBrightness eBrightness)
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp
index 9314bb52aa..681fc608a9 100644
--- a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp
@@ -333,7 +333,7 @@ void CLCDGfx::DrawText(int nX,int nY,int nWidth,tstring strText)
 		DrawText(nX,nY,(strText.substr(0,iMaxChars) + _T("...")).c_str());
 	}
 	else DrawText(nX,nY,strText.c_str());
-	free(piWidths);
+	delete[] piWidths;
 }
 
 //************************************************************************
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp
index 7d531cbea8..647cf8bf49 100644
--- a/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/CLCDInput.cpp
@@ -534,7 +534,7 @@ void CLCDInput::MoveMarker(int iDir,int iMove,bool bShift)
 				}
 			}
 			
-			free(piWidths);
+			delete[] piWidths;
 
 			if(m_Marker[0].iPosition == -1)
 			{
@@ -598,6 +598,10 @@ void CLCDInput::UpdateOffsets(int iModified)
 {
 	if(m_vLineOffsets.size() == 0 && m_strText.empty())
 		return;
+
+	HDC hDC = CreateCompatibleDC(NULL);
+	if(NULL == hDC)
+		return;
 	
 	// Reset the marker
 	m_Marker[0].iXLine = 0;
@@ -613,9 +617,6 @@ void CLCDInput::UpdateOffsets(int iModified)
 	SIZE sizeWord = {0, 0};
 	SIZE sizeChar = {0, 0};
 	SIZE sizeLine =  {0, 0};
-	HDC hDC = CreateCompatibleDC(NULL);
-	if(NULL == hDC)
-		return;
 	SelectObject(hDC, m_hFont);   
 
 	int iLine = -1;
@@ -778,7 +779,7 @@ void CLCDInput::UpdateOffsets(int iModified)
 	}
 
 finished:
-	free(piWidths);
+	delete[] piWidths;
 	DeleteObject(hDC);
 	
 	if(m_pScrollbar)
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp
index e2680a364f..c5fecce751 100644
--- a/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/CLCDLabel.cpp
@@ -183,7 +183,7 @@ void CLCDLabel::UpdateCutOffIndex()
 			m_vLines.push_back(m_strText.substr(i,iMaxChars));
 			i += iMaxChars;
 		}
-		free(piExtents);
+		delete[] piExtents;
 	}
 	else
 		m_vLines.push_back(m_strText);
@@ -206,7 +206,7 @@ void CLCDLabel::UpdateCutOffIndex()
 		}
 		(*--m_vLines.end()) = (*--m_vLines.end()).substr(0,iMaxChars) + _T("...");
 	}
-	free(piWidths);
+	delete[] piWidths;
 
 	DeleteObject(hDC);
 
diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp
index d1abb9d704..a2cd753099 100644
--- a/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.cpp
@@ -338,7 +338,7 @@ void CLCDTextLog::WrapMessage(CLogEntry *pEntry)
 			i += iMaxChars;
 		}
 	}
-	free(piExtents);
+	delete[] piExtents;
 	/*
 	while(i<=iLen)
 	{
diff --git a/plugins/MirandaG15/src/LCDFramework/misc.cpp b/plugins/MirandaG15/src/LCDFramework/misc.cpp
index 3e861fb529..eb9f2edcf8 100644
--- a/plugins/MirandaG15/src/LCDFramework/misc.cpp
+++ b/plugins/MirandaG15/src/LCDFramework/misc.cpp
@@ -79,7 +79,7 @@ toNarrowString( const wchar_t* pStr , int len )
     // nb: slightly naughty to write directly into the string like this
     string buf ;
     buf.resize( nChars  ) ;
-	char *test = (char*)malloc((nChars+1)*sizeof(char));
+	//char *test = (char*)malloc((nChars+1)*sizeof(char));
 	WideCharToMultiByte( CP_ACP , 0 , pStr , len , 
           const_cast<char*>(buf.c_str()), nChars , NULL , NULL ) ; 
 
-- 
cgit v1.2.3