aboutsummaryrefslogtreecommitdiff
path: root/libs/plugin_python/src/mobase/deprecation.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/plugin_python/src/mobase/deprecation.cpp
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/plugin_python/src/mobase/deprecation.cpp')
-rw-r--r--libs/plugin_python/src/mobase/deprecation.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/libs/plugin_python/src/mobase/deprecation.cpp b/libs/plugin_python/src/mobase/deprecation.cpp
new file mode 100644
index 0000000..958712d
--- /dev/null
+++ b/libs/plugin_python/src/mobase/deprecation.cpp
@@ -0,0 +1,55 @@
+#include "deprecation.h"
+
+#include <filesystem>
+#include <set>
+
+#include <pybind11/pybind11.h>
+
+#include <QCoreApplication>
+
+#include <uibase/log.h>
+
+namespace py = pybind11;
+
+namespace mo2::python {
+
+ void show_deprecation_warning(std::string_view name, std::string_view message,
+ bool show_once)
+ {
+
+ // Contains the list of filename / line number for which a deprecation
+ // warning has already been shown.
+ static std::set<std::pair<std::string, int>> DeprecatedLines;
+
+ // Find the caller:
+ auto inspect = py::module_::import("inspect");
+ auto current_frame = inspect.attr("currentframe")();
+ py::sequence callable_frame = inspect.attr("getouterframes")(current_frame, 2);
+ auto last_frame = callable_frame[py::int_(-1)];
+ auto filename = last_frame.attr("filename").cast<std::string>();
+ auto function = last_frame.attr("function").cast<std::string>();
+ auto lineno = last_frame.attr("lineno").cast<int>();
+
+ // Only show once if requested:
+ if (show_once && DeprecatedLines.contains({filename, lineno})) {
+ return;
+ }
+
+ // Register the deprecation:
+ DeprecatedLines.emplace(filename, lineno);
+
+ auto path = relative(std::filesystem::path(filename),
+ QCoreApplication::applicationDirPath().toStdWString());
+
+ // Show the message:
+ if (message.empty()) {
+ MOBase::log::warn("[deprecated] {} in {} [{}:{}].", name, function,
+ path.native(), lineno);
+ }
+ else {
+ MOBase::log::warn("[deprecated] {} in {} [{}:{}]: {}", name, function,
+ path.native(), lineno, message);
+ }
+ }
+
+} // namespace mo2::python