Skip to content

Commit

Permalink
free string returned by mpv
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Feb 7, 2023
1 parent a3f55ec commit 11043cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion source/views/context_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void ContextMenu::drawAudioDeviceList() {

void ContextMenu::drawTracklist(const char *type, const char *prop) {
auto items = mpv->trackList();
auto value = mpv->property(prop);
char *value = mpv->property(prop);
if (ImGui::BeginMenuEx("Tracks", ICON_FA_LIST)) {
if (ImGui::MenuItem("Disable", nullptr, strcmp(value, "no") == 0))
mpv->commandv("cycle-values", prop, "no", "auto", nullptr);
Expand All @@ -259,6 +259,7 @@ void ContextMenu::drawTracklist(const char *type, const char *prop) {
}
ImGui::EndMenu();
}
mpv_free(value);
}

void ContextMenu::drawChapterlist(std::vector<Mpv::ChapterItem> items) {
Expand Down
3 changes: 2 additions & 1 deletion source/views/quickview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ bool Quickview::toggleButton(bool toggle, const char *tooltip) {
void Quickview::drawTracks(const char *type, const char *prop) {
ImGui::Text("Tracks");
alignRight(ICON_FA_TOGGLE_ON);
const char *state = mpv->property(prop);
char *state = mpv->property(prop);
if (toggleButton(state && !iequals(state, "no"), "Toggle Tracks"))
mpv->commandv("cycle-values", prop, "no", "auto", nullptr);
mpv_free(state);
if (ImGui::BeginListBox("##tracks", ImVec2(-FLT_MIN, 3 * ImGui::GetTextLineHeightWithSpacing()))) {
auto items = mpv->trackList();
if (items.empty()) ImGui::TextDisabled("<Empty>");
Expand Down

0 comments on commit 11043cb

Please sign in to comment.