From 6d5c5b78251ea7256d51cdcc67787573836efb6a Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Tue, 21 Mar 2023 07:35:41 +0100 Subject: [PATCH] Hopefully addressed #148 while detecting the patches folder Signed-off-by: Alexis Maiquez --- .../Application/CWallpaperApplication.cpp | 31 ++++++++++++++++--- src/WallpaperEngine/Assets/CDirectory.cpp | 2 +- .../Render/Drivers/Output/CX11Output.cpp | 6 ---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index 5c5d7c5..954ef02 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -40,11 +40,32 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const container.addPkg (basepath / "scene.pkg"); container.addPkg (basepath / "gifscene.pkg"); container.add (new CDirectory (this->m_context.assets)); -#if !NDEBUG - container.add (new CDirectory ("../share/")); -#else - container.add (new CDirectory (DATADIR)); -#endif /* DEBUG */ + + // add two possible patches directories to the container + // hopefully one sticks + bool relative = true; + bool absolute = true; + + try + { + container.add (new CDirectory ("../share/")); + } + catch (std::runtime_error& ex) + { + relative = false; + } + + try + { + container.add (new CDirectory (DATADIR)); + } + catch (std::runtime_error& ex) + { + absolute = false; + } + + if (!relative && !absolute) + sLog.error ("WARNING: Shader patches directory cannot be found, this might make some backgrounds not work properly"); // TODO: move this somewhere else? CVirtualContainer* virtualContainer = new CVirtualContainer (); diff --git a/src/WallpaperEngine/Assets/CDirectory.cpp b/src/WallpaperEngine/Assets/CDirectory.cpp index 97c479d..46634ca 100644 --- a/src/WallpaperEngine/Assets/CDirectory.cpp +++ b/src/WallpaperEngine/Assets/CDirectory.cpp @@ -8,7 +8,7 @@ using namespace WallpaperEngine::Assets; -CDirectory::CDirectory (std::filesystem::path basepath) : +CDirectory::CDirectory (std::filesystem::path basepath) : m_basepath (std::move(basepath)) { // ensure the specified path exists diff --git a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp b/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp index 7b1d2cf..530d803 100644 --- a/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp +++ b/src/WallpaperEngine/Render/Drivers/Output/CX11Output.cpp @@ -13,9 +13,7 @@ void CustomXIOErrorExitHandler (Display* dsp, void* userdata) { auto context = static_cast (userdata); -#if !NDEBUG sLog.debugerror ("Critical XServer error detected. Attempting to recover..."); -#endif /* DEBUG */ // refetch all the resources context->reset (); @@ -23,9 +21,7 @@ void CustomXIOErrorExitHandler (Display* dsp, void* userdata) int CustomXErrorHandler (Display* dpy, XErrorEvent* event) { -#if !NDEBUG sLog.debugerror ("Detected X error"); -#endif /* DEBUG */ // call the original handler so we can keep some information reporting originalErrorHandler (dpy, event); @@ -35,9 +31,7 @@ int CustomXErrorHandler (Display* dpy, XErrorEvent* event) int CustomXIOErrorHandler (Display* dsp) { -#if !NDEBUG sLog.debugerror ("Detected X error"); -#endif /* DEBUG */ return 0; }