Skip to content

Commit

Permalink
Filename: Use RAII
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed Jul 22, 2024
1 parent b098600 commit 7f2a552
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/lv2/Lv2SubPluginFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ void Lv2SubPluginFeatures::fillDescriptionWidget(QWidget* parent,
{
const LilvNode* libraryUriNode = lilv_plugin_get_bundle_uri(plug);
const char* libraryUri = lilv_node_as_uri(libraryUriNode);
char* filename = lilv_file_uri_parse(libraryUri, nullptr);
auto filename = std::unique_ptr<char, void(*)(char*)>(
lilv_file_uri_parse(libraryUri, nullptr),
[](char* ptr) { lilv_free(ptr); }
);
if (filename)
{
new QLabel(QObject::tr("File: %1").arg(filename), parent);
lilv_free(filename);
new QLabel(QObject::tr("File: %1").arg(filename.get()), parent);
}
}
}
Expand Down

0 comments on commit 7f2a552

Please sign in to comment.