summarylogtreecommitdiffstats
path: root/infekt_fix_nfo_view_ctrl.patch
blob: 0e1c2a8dac6767b3d599ccc28607a5da14780273 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--- a/src/gtk/nfo_view_ctrl.h
+++ b/src/gtk/nfo_view_ctrl.h
@@ -54,8 +55,8 @@
 	void ForceRedraw();
 
 	/* NFO data and renderer stuff */
-	CNFOData* m_pNfo;
-	CNFOData* m_pNfoTextOnly;
+	std::shared_ptr<CNFOData> m_pNfo;
+	std::shared_ptr<CNFOData> m_pNfoTextOnly;
 
 	CNFORenderer m_renderer;
 	CNFORenderer m_classicRenderer;

--- a/src/gtk/nfo_view_ctrl.cpp
+++ b/src/gtk/nfo_view_ctrl.cpp
@@ -26,7 +26,6 @@
 	m_classicRenderer(true),
 	m_textOnlyRenderer(true)
 {
-	m_pNfoTextOnly = m_pNfo = NULL;
 	m_centerNfo = true;
 	m_mode = NFO_VIEW_RENDERED;
 
@@ -43,11 +42,11 @@
 	m_classicRenderer.UnAssignNFO();
 	m_textOnlyRenderer.UnAssignNFO();
 
-	delete m_pNfo;
-	delete m_pNfoTextOnly;
+	m_pNfo.reset();
+	m_pNfoTextOnly.reset();
 
 	// load new file:
-	m_pNfo = new CNFOData();
+	m_pNfo = std::make_shared<CNFOData>();
 
 	if(m_pNfo->LoadFromFile(a_filePath))
 	{
@@ -56,9 +55,7 @@
 	}
 
 	// if loading failed, clean up:
-	delete m_pNfo;
-	m_pNfo = NULL;
-
+	m_pNfo.reset();
 	return false;
 }
 
@@ -82,14 +79,14 @@
 		{
 			// generate text-only data
 
-			const std::string l_stripped = CNFOData::GetStrippedTextUtf8(m_pNfo->GetTextWide());
-			m_pNfoTextOnly = new CNFOData();
+			std::wstring wideText = m_pNfo->GetTextWide();
+			std::string strippedText(wideText.begin(), wideText.end()); // Assuming a basic conversion here
+			m_pNfoTextOnly = std::make_shared<CNFOData>();
 			m_pNfoTextOnly->SetCharsetToTry(NFOC_UTF8);
 
-			if(!m_pNfoTextOnly->LoadFromMemory((const unsigned char*)l_stripped.c_str(), l_stripped.size()))
+			if(!m_pNfoTextOnly->LoadFromMemory((const unsigned char*)strippedText.c_str(), strippedText.size()))
 			{
-				delete m_pNfoTextOnly;
-				m_pNfoTextOnly = NULL;
+				m_pNfoTextOnly.reset();
 			}
 			else
 			{
@@ -180,7 +177,7 @@
 		case NFO_VIEW_TEXTONLY: return &m_textOnlyRenderer;
 	}
 
-	return NULL;
+	return nullptr;
 }