OrcaSlicer latest
OrcaSlicer
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()

void Slic3r::instance_check_internal::delete_lockfile ( )
static
208 {
209 //BOOST_LOG_TRIVIAL(debug) << "shuting down with lockfile: " << l_created_lockfile;
211 {
212 std::string path = data_dir() + "/cache/" + GUI::wxGetApp().get_instance_hash_string() + ".lock";
213 if( remove( path.c_str() ) != 0 )
214 BOOST_LOG_TRIVIAL(error) << "Failed to delete lockfile " << path;
215 //else
216 // BOOST_LOG_TRIVIAL(error) << "success delete lockfile " << path;
217#ifdef __APPLE__
218 send_message_mac_closing(GUI::wxGetApp().get_instance_hash_string(),GUI::wxGetApp().get_instance_hash_string());
219#endif
220 }
221 }
static bool s_created_lockfile
Definition InstanceCheck.cpp:74
const std::string & data_dir()
Definition utils.cpp:365
void send_message_mac_closing(const std::string &msg, const std::string &version)
Definition InstanceCheckMac.mm:63

References Slic3r::data_dir(), 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()

bool Slic3r::instance_check_internal::get_lock ( const std::string & name,
const std::string & path )
static
172 {
173 std::string dest_dir = path + name;
174 BOOST_LOG_TRIVIAL(debug) <<"full lock path: "<< dest_dir;
175 struct flock fl;
176 int fdlock;
177 fl.l_type = F_WRLCK;
178 fl.l_whence = SEEK_SET;
179 fl.l_start = 0;
180 fl.l_len = 1;
181
182 if (! boost::filesystem::is_directory(path)) {
183 BOOST_LOG_TRIVIAL(debug) << "get_lock(): datadir does not exist yet, creating...";
184 if (! boost::filesystem::create_directories(path))
185 BOOST_LOG_TRIVIAL(debug) << "get_lock(): unable to create datadir !!!";
186 }
187
188 if ((fdlock = open(dest_dir.c_str(), O_WRONLY | O_CREAT, 0666)) == -1) {
189 BOOST_LOG_TRIVIAL(debug) << "Not creating lockfile.";
190 return true;
191 }
192
193 if (fcntl(fdlock, F_SETLK, &fl) == -1) {
194 BOOST_LOG_TRIVIAL(debug) << "Not creating lockfile.";
195 return true;
196 }
197
198 BOOST_LOG_TRIVIAL(debug) << "Creating lockfile.";
199 s_created_lockfile = true;
200 return false;
201 }

References s_created_lockfile.

Referenced by Slic3r::instance_check().

Here is the caller graph for this function:

◆ process_command_line()

CommandLineAnalysis Slic3r::instance_check_internal::process_command_line ( int argc,
char ** argv )
static
82 {
84 //if (argc < 2)
85 // return ret;
86 std::vector<std::string> arguments { argv[0] };
87 for (int i = 1; i < argc; ++i) {
88 const std::string token = argv[i];
89 // Processing of boolean command line arguments shall match DynamicConfig::read_cli().
90 if (token == "--single-instance")
91 ret.should_send = true;
92 else if (token == "--no-single-instance")
93 ret.should_send = false;
94 else
95 arguments.emplace_back(token);
96 }
97 ret.cl_string = escape_strings_cstyle(arguments);
98 BOOST_LOG_TRIVIAL(debug) << "single instance: " <<
99 (ret.should_send.has_value() ? (*ret.should_send ? "true" : "false") : "undefined") <<
100 ". other params: " << ret.cl_string;
101 return ret;
102 }
std::optional< bool > should_send
Definition InstanceCheck.cpp:78
std::string cl_string
Definition InstanceCheck.cpp:79
std::string escape_strings_cstyle(const std::vector< std::string > &strs)
Definition Config.cpp:99

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().