Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::instance_check_internal Namespace Reference

Classes

struct  CommandLineAnalysis
 

Functions

static CommandLineAnalysis process_command_line (int argc, char **argv)
 
static bool get_lock (const std::string &name, const std::string &path)
 
static void delete_lockfile ()
 

Variables

static bool s_created_lockfile = false
 

Class Documentation

◆ Slic3r::instance_check_internal::CommandLineAnalysis

struct Slic3r::instance_check_internal::CommandLineAnalysis
+ Collaboration diagram for Slic3r::instance_check_internal::CommandLineAnalysis:
Class Members
string cl_string
optional< bool > should_send

Function Documentation

◆ delete_lockfile()

static void Slic3r::instance_check_internal::delete_lockfile ( )
static
192 {
193 //BOOST_LOG_TRIVIAL(debug) << "shuting down with lockfile: " << l_created_lockfile;
194 if (s_created_lockfile)
195 {
196 std::string path = data_dir() + "/cache/" + GUI::wxGetApp().get_instance_hash_string() + ".lock";
197 if( remove( path.c_str() ) != 0 )
198 BOOST_LOG_TRIVIAL(error) << "Failed to delete lockfile " << path;
199 //else
200 // BOOST_LOG_TRIVIAL(error) << "success delete lockfile " << path;
201#ifdef __APPLE__
202 // Partial fix of #7583
203 // On price of incorrect working of single instances on older OSX
204 if (wxPlatformInfo::Get().GetOSMajorVersion() > 12)
205 send_message_mac_closing(GUI::wxGetApp().get_instance_hash_string(),GUI::wxGetApp().get_instance_hash_string());
206#endif
207 }
208 }
const std::string & data_dir()
Definition utils.cpp:206
void send_message_mac_closing(const std::string &msg, const std::string &version)
Definition InstanceCheckMac.mm:63
static char error[256]
Definition tga.cpp:50

References Slic3r::data_dir(), error, s_created_lockfile, and Slic3r::send_message_mac_closing().

Referenced by Slic3r::GUI::OtherInstanceMessageHandler::shutdown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_lock()

static bool Slic3r::instance_check_internal::get_lock ( const std::string &  name,
const std::string &  path 
)
static
156 {
157 std::string dest_dir = path + name;
158 BOOST_LOG_TRIVIAL(debug) <<"full lock path: "<< dest_dir;
159 struct flock fl;
160 int fdlock;
161 fl.l_type = F_WRLCK;
162 fl.l_whence = SEEK_SET;
163 fl.l_start = 0;
164 fl.l_len = 1;
165
166 if (! boost::filesystem::is_directory(path)) {
167 BOOST_LOG_TRIVIAL(debug) << "get_lock(): datadir does not exist yet, creating...";
168 if (! boost::filesystem::create_directories(path))
169 BOOST_LOG_TRIVIAL(debug) << "get_lock(): unable to create datadir !!!";
170 }
171
172 if ((fdlock = open(dest_dir.c_str(), O_WRONLY | O_CREAT, 0666)) == -1) {
173 BOOST_LOG_TRIVIAL(debug) << "Not creating lockfile.";
174 return true;
175 }
176
177 if (fcntl(fdlock, F_SETLK, &fl) == -1) {
178 BOOST_LOG_TRIVIAL(debug) << "Not creating lockfile.";
179 return true;
180 }
181
182 BOOST_LOG_TRIVIAL(debug) << "Creating lockfile.";
183 s_created_lockfile = true;
184 return false;
185 }
static bool s_created_lockfile
Definition InstanceCheck.cpp:55
#define SEEK_SET

References s_created_lockfile, and SEEK_SET.

Referenced by Slic3r::instance_check().

+ Here is the caller graph for this function:

◆ process_command_line()

static CommandLineAnalysis Slic3r::instance_check_internal::process_command_line ( int  argc,
char **  argv 
)
static
63 {
65 //if (argc < 2)
66 // return ret;
67 std::vector<std::string> arguments { argv[0] };
68 for (int i = 1; i < argc; ++i) {
69 const std::string token = argv[i];
70 // Processing of boolean command line arguments shall match DynamicConfig::read_cli().
71 if (token == "--single-instance")
72 ret.should_send = true;
73 else if (token == "--no-single-instance")
74 ret.should_send = false;
75 else
76 arguments.emplace_back(token);
77 }
78 ret.cl_string = escape_strings_cstyle(arguments);
79 BOOST_LOG_TRIVIAL(debug) << "single instance: " <<
80 (ret.should_send.has_value() ? (*ret.should_send ? "true" : "false") : "undefined") <<
81 ". other params: " << ret.cl_string;
82 return ret;
83 }
std::optional< bool > should_send
Definition InstanceCheck.cpp:59
std::string cl_string
Definition InstanceCheck.cpp:60

References Slic3r::instance_check_internal::CommandLineAnalysis::cl_string, Slic3r::escape_strings_cstyle(), and Slic3r::instance_check_internal::CommandLineAnalysis::should_send.

Referenced by Slic3r::instance_check().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ s_created_lockfile

bool Slic3r::instance_check_internal::s_created_lockfile = false
static

Referenced by delete_lockfile(), and get_lock().