From aaa5c04b9da9b28c641ec165bfa9c91b3d4ca21e Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 26 Nov 2024 06:20:14 -0500 Subject: [PATCH] Remove .c_str() calls for string::f() arguments. --- src/Quantity.cpp | 12 ++++++------ src/app/MenuBar.cpp | 18 +++++++++--------- src/app/ModuleWidget.cpp | 6 +++--- src/app/RackWidget.cpp | 2 +- src/plugin.cpp | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Quantity.cpp b/src/Quantity.cpp index 5e438d1a..b9facbfe 100644 --- a/src/Quantity.cpp +++ b/src/Quantity.cpp @@ -60,14 +60,14 @@ static void teVarsInit() { }; for (const Note& note : notes) { // Example: c, cs (or c#), and cb - teVariables.push_back({string::f("%s", note.name.c_str()), 440.f * std::pow(2.0, (note.semi - 9) / 12.f)}); - teVariables.push_back({string::f("%ss", note.name.c_str()), 440.f * std::pow(2.0, (note.semi - 9 + 1) / 12.f)}); - teVariables.push_back({string::f("%sb", note.name.c_str()), 440.f * std::pow(2.0, (note.semi - 9 - 1) / 12.f)}); + teVariables.push_back({string::f("%s", note.name), 440.f * std::pow(2.0, (note.semi - 9) / 12.f)}); + teVariables.push_back({string::f("%ss", note.name), 440.f * std::pow(2.0, (note.semi - 9 + 1) / 12.f)}); + teVariables.push_back({string::f("%sb", note.name), 440.f * std::pow(2.0, (note.semi - 9 - 1) / 12.f)}); for (int oct = 0; oct <= 9; oct++) { // Example: c4, cs4 (or c#4), and cb4 - teVariables.push_back({string::f("%s%d", note.name.c_str(), oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9) / 12.f)}); - teVariables.push_back({string::f("%ss%d", note.name.c_str(), oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9 + 1) / 12.f)}); - teVariables.push_back({string::f("%sb%d", note.name.c_str(), oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9 - 1) / 12.f)}); + teVariables.push_back({string::f("%s%d", note.name, oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9) / 12.f)}); + teVariables.push_back({string::f("%ss%d", note.name, oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9 + 1) / 12.f)}); + teVariables.push_back({string::f("%sb%d", note.name, oct), 440.f * std::pow(2.0, oct - 4 + (note.semi - 9 - 1) / 12.f)}); } } diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 2b064547..9dff32a4 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -139,7 +139,7 @@ struct EditButton : MenuButton { struct UndoItem : ui::MenuItem { void step() override { - text = string::f(string::translate("MenuBar.edit.undo").c_str(), APP->history->getUndoName().c_str()); + text = string::f(string::translate("MenuBar.edit.undo"), APP->history->getUndoName()); disabled = !APP->history->canUndo(); MenuItem::step(); } @@ -151,7 +151,7 @@ struct EditButton : MenuButton { struct RedoItem : ui::MenuItem { void step() override { - text = string::f(string::translate("MenuBar.edit.redo").c_str(), APP->history->getRedoName().c_str()); + text = string::f(string::translate("MenuBar.edit.redo"), APP->history->getRedoName()); disabled = !APP->history->canRedo(); MenuItem::step(); } @@ -428,9 +428,9 @@ struct ViewButton : MenuButton { APP->scene->rackScroll->zoomToModules(); })); - menu->addChild(createIndexPtrSubmenuItem(string::translate("MenuBar.view.mousewheelzoom"), { - string::f(string::translate("MenuBar.view.mouseWheelZoom.scroll").c_str(), RACK_MOD_CTRL_NAME), - string::f(string::translate("MenuBar.view.mouseWheelZoom.zoom").c_str(), RACK_MOD_CTRL_NAME) + menu->addChild(createIndexPtrSubmenuItem(string::translate("MenuBar.view.mouseWheelZoom"), { + string::f(string::translate("MenuBar.view.mouseWheelZoom.scroll"), RACK_MOD_CTRL_NAME), + string::f(string::translate("MenuBar.view.mouseWheelZoom.zoom"), RACK_MOD_CTRL_NAME) }, &settings::mouseWheelZoom)); menu->addChild(new ui::MenuSeparator); @@ -788,7 +788,7 @@ struct SyncUpdateItem : ui::MenuItem { ui::Menu* menu = new ui::Menu; if (update.minRackVersion != "") { - menu->addChild(createMenuLabel(string::f(string::translate("MenuBar.library.requiresRack").c_str(), update.minRackVersion.c_str()))); + menu->addChild(createMenuLabel(string::f(string::translate("MenuBar.library.requiresRack"), update.minRackVersion))); } if (update.changelogUrl != "") { @@ -997,7 +997,7 @@ struct HelpButton : MenuButton { }, [=](size_t i) { settings::language = get(languages, i, "en"); // Request restart - std::string msg = string::f(string::translate("MenuBar.help.language.restart").c_str(), string::translate("language").c_str()); + std::string msg = string::f(string::translate("MenuBar.help.language.restart"), string::translate("language")); if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, msg.c_str())) { APP->window->close(); } @@ -1030,12 +1030,12 @@ struct HelpButton : MenuButton { })); if (library::isAppUpdateAvailable()) { - menu->addChild(createMenuItem(string::f(string::translate("MenuBar.help.update").c_str(), APP_NAME.c_str()), APP_VERSION + " → " + library::appVersion, [=]() { + menu->addChild(createMenuItem(string::f(string::translate("MenuBar.help.update"), APP_NAME), APP_VERSION + " → " + library::appVersion, [=]() { system::openBrowser(library::appDownloadUrl); })); } else if (!settings::autoCheckUpdates && !settings::devMode) { - menu->addChild(createMenuItem(string::f(string::translate("MenuBar.help.checkUpdate").c_str(), APP_NAME.c_str()), "", [=]() { + menu->addChild(createMenuItem(string::f(string::translate("MenuBar.help.checkUpdate"), APP_NAME), "", [=]() { std::thread t([&]() { library::checkAppUpdate(); }); diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index ccbcead1..16f3b33e 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -673,7 +673,7 @@ void ModuleWidget::save(std::string filename) { FILE* file = std::fopen(filename.c_str(), "w"); if (!file) { - std::string message = string::f("Could not save preset to file %s", filename.c_str()); + std::string message = string::f("Could not save preset to file %s", filename); osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, message.c_str()); return; } @@ -691,7 +691,7 @@ void ModuleWidget::saveTemplate() { void ModuleWidget::saveTemplateDialog() { if (hasTemplate()) { - std::string message = string::f("Overwrite default preset for %s?", model->getFullName().c_str()); + std::string message = string::f("Overwrite default preset for %s?", model->getFullName()); if (!osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, message.c_str())) return; } @@ -711,7 +711,7 @@ void ModuleWidget::clearTemplate() { } void ModuleWidget::clearTemplateDialog() { - std::string message = string::f("Delete default preset for %s?", model->getFullName().c_str()); + std::string message = string::f("Delete default preset for %s?", model->getFullName()); if (!osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, message.c_str())) return; clearTemplate(); diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index a184c745..8fec7221 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -1126,7 +1126,7 @@ void RackWidget::saveSelection(std::string path) { FILE* file = std::fopen(path.c_str(), "w"); if (!file) { - std::string message = string::f("Could not save selection to file %s", path.c_str()); + std::string message = string::f("Could not save selection to file %s", path); osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, message.c_str()); return; } diff --git a/src/plugin.cpp b/src/plugin.cpp index 68940de7..fefa46d8 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -234,7 +234,7 @@ static void extractPackages(std::string path) { } catch (Exception& e) { WARN("Plugin package %s failed to extract: %s", packagePath.c_str(), e.what()); - message += string::f("Could not extract plugin package %s\n", packagePath.c_str()); + message += string::f("Could not extract plugin package %s\n", packagePath); continue; } // Remove package