feat: add instance guard
This commit is contained in:
parent
74a80907f9
commit
76db90bd46
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -15,4 +15,7 @@
|
||||
url = https://github.com/btzy/nativefiledialog-extended/
|
||||
[submodule "src/ui/impl/webview/lib/soundux-ui"]
|
||||
path = src/ui/impl/webview/lib/soundux-ui
|
||||
url = https://github.com/Soundux/soundux-ui
|
||||
url = https://github.com/Soundux/soundux-ui
|
||||
[submodule "lib/InstanceGuard"]
|
||||
path = lib/InstanceGuard
|
||||
url = https://github.com/Grandbrain/InstanceGuard
|
||||
|
@ -13,6 +13,7 @@ add_executable(soundux ${src})
|
||||
target_include_directories(soundux PRIVATE "lib/miniaudio")
|
||||
target_include_directories(soundux PRIVATE "lib/fancypp/include")
|
||||
target_include_directories(soundux PRIVATE "lib/json/single_include")
|
||||
target_include_directories(soundux PRIVATE "lib/InstanceGuard/Source")
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
@ -29,7 +30,8 @@ endif()
|
||||
|
||||
add_subdirectory(src/ui/impl/webview/lib/webview)
|
||||
add_subdirectory(lib/nativefiledialog-extended)
|
||||
target_link_libraries(soundux PUBLIC webview nfd)
|
||||
add_subdirectory(lib/InstanceGuard/Source)
|
||||
target_link_libraries(soundux PUBLIC webview nfd InstanceGuard)
|
||||
|
||||
# [[ Build Frontend ]]
|
||||
if (MSVC)
|
||||
|
1
lib/InstanceGuard
Submodule
1
lib/InstanceGuard
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 5e3efce2036d744c04f1b190536d7c57e567040d
|
@ -1,8 +1,17 @@
|
||||
#include "core/global/globals.hpp"
|
||||
#include "ui/impl/webview/webview.hpp"
|
||||
#include <InstanceGuard.hpp>
|
||||
#include <fancy.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
InstanceGuard::InstanceGuard guard("soundux-guard");
|
||||
if (guard.IsAnotherInstanceRunning())
|
||||
{
|
||||
Fancy::fancy.logTime().failure() << "Another Instance is already running!" << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
if (!Soundux::Globals::gPulse.isSwitchOnConnectLoaded())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user