aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-16 01:53:49 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-16 01:53:49 +0200
commit2fed063bf167dcb8f900c4a1f11b0a02ae115d16 (patch)
tree99b41b649fb6a1b6683bd90cd38ab894dd526ce3 /c/episodelistview.cpp
parent84c3dd3587e219caa80adc2070f0e9fe004c27bc (diff)
downloadEpisodeBrowser-2fed063bf167dcb8f900c4a1f11b0a02ae115d16.tar.gz
Rewrite TszFromSz as TsmFromSz.
I.e. using std::basic_string<TCHAR> instead of TCHAR *. This removes all unmanaged frees.
Diffstat (limited to 'c/episodelistview.cpp')
-rw-r--r--c/episodelistview.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 1a41986..a802f90 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -287,11 +287,10 @@ void EpisodeListView::Update()
extern char g_szLimitScreenwriter[];
extern int g_bViewTVOriginal, g_bViewWatched;
- if (g_szLimitScreenwriter[0])
- if (!Pl("episode_data","episode_datum",
- iEp,"Screenwriter",g_szLimitScreenwriter))
- continue;
-
+ if (g_szLimitScreenwriter[0]
+ && !Pl("episode_data","episode_datum",iEp,"Screenwriter",g_szLimitScreenwriter))
+ continue;
+
if (!g_bViewWatched)
if (Pl("track_episodes","watched",iEp)) continue;
@@ -356,30 +355,26 @@ void EpisodeListView::Update()
/* Update episode name and rating. */
void EpisodeListView::UpdateItem(LPLVITEM lpLvi)
{
+ std::basic_string<TCHAR> tsmName;
char *szName;
int iRating;
- TCHAR *tszName;
static TCHAR tszRating[3];
- tszName = NULL;
if (!Pl("episode_data","episode_title",lpLvi->lParam,&szName)) {
if (!Pl("episode_data","update_episode_data")) goto r;
if (!Pl("episode_data","episode_title",lpLvi->lParam,&szName))
goto r;
}
- tszName = TszFromSz(szName, CP_UTF8);
- if (tszName)
- ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSITITLE, tszName);
+ tsmName = TsmFromSz(szName, CP_UTF8);
+ ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSITITLE, tsmName.data());
r: if (!Pl("episode_data","episode_rating",lpLvi->lParam,&iRating)) {
ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSIRATING, TEXT(""));
- goto f;
+ return;
}
_stprintf_s(tszRating, sizeof(tszRating), TEXT("%d"), iRating);
ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSIRATING, tszRating);
-
-f: if (tszName) free(tszName);
}
LRESULT CALLBACK EpisodeListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)