aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/LuminaSingleApplication.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-09-06 17:59:57 -0400
committerKen Moore <ken@ixsystems.com>2018-09-06 17:59:57 -0400
commitf1fce23e23d0a61ce588c5c089792a1e71dc0500 (patch)
treedd8fc110244fc6396f3a930ea4d0f7e022956f3f /src-qt5/core/libLumina/LuminaSingleApplication.cpp
parentCheckpoint commit for some uncommitted changed to lumina-desktop-unified (diff)
downloadlumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.tar.gz
lumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.tar.bz2
lumina-f1fce23e23d0a61ce588c5c089792a1e71dc0500.zip
Fix up the launching of the desktop session
1. Clear out the lockfiles for a session before launching it 2. Provide some mechanisms for returning lockfile paths without creating a new single-instance session. 3. A couple other random commits I still had staged on my laptop (settings menu tweak)
Diffstat (limited to 'src-qt5/core/libLumina/LuminaSingleApplication.cpp')
-rw-r--r--src-qt5/core/libLumina/LuminaSingleApplication.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.cpp b/src-qt5/core/libLumina/LuminaSingleApplication.cpp
index 379ac02d..0c04229c 100644
--- a/src-qt5/core/libLumina/LuminaSingleApplication.cpp
+++ b/src-qt5/core/libLumina/LuminaSingleApplication.cpp
@@ -18,14 +18,7 @@ LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname)
this->setAttribute(Qt::AA_UseHighDpiPixmaps);
if(appname!="lumina-desktop"){ cTrans = LUtils::LoadTranslation(this, appname); }//save the translator for later
//Initialize a couple convenience internal variables
- cfile = QDir::tempPath()+"/.LSingleApp-%1-%2-%3";
- QString username = QString::number(getuid());
- //For locking the process use the official process name - not the user input (no masking)
- appname = this->applicationName();
- QString display = QString(getenv("DISPLAY"));
- if(display.startsWith(":")){ display.remove(0,1); }
- display = display.section(".",0,0);
- cfile = cfile.arg( username, appname, display );
+ cfile = getLockfileName(this->applicationName()); //do not allow masking the utility name
lockfile = new QLockFile(cfile+"-lock");
lockfile->setStaleLockTime(0); //long-lived processes
for(int i=1; i<argc; i++){
@@ -59,6 +52,26 @@ LSingleApplication::~LSingleApplication(){
}
}
+QString LSingleApplication::getLockfileName(QString appname){
+ QString path = QDir::tempPath()+"/.LSingleApp-%1-%2-%3";
+ QString username = QString::number(getuid());
+ QString display = QString(getenv("DISPLAY"));
+ if(display.startsWith(":")){ display.remove(0,1); }
+ display = display.section(".",0,0);
+ path = path.arg( username, appname, display );
+ return path;
+}
+
+void LSingleApplication::removeLocks(QString appname){
+ QString path = getLockfileName(appname);
+ if(QFile::exists(path+"-lock")){
+ QFile::remove(path+"-lock");
+ }
+ if(QFile::exists(path)){
+ QFile::remove(path);
+ }
+}
+
bool LSingleApplication::isPrimaryProcess(){
return (isActive || isBypass);
}
bgstack15