Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
4384320d
Commit
4384320d
authored
Jan 23, 2016
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect running instance and prevent loading second instance.
parent
9e68f04a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
main.cc
src/main.cc
+12
-0
No files found.
src/main.cc
View file @
4384320d
...
@@ -35,6 +35,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -35,6 +35,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGCApplication.h"
#include "QGCApplication.h"
#define SINGLE_INSTANCE_PORT 14499
#ifndef __mobile__
#ifndef __mobile__
#include "QGCSerialPortInfo.h"
#include "QGCSerialPortInfo.h"
#endif
#endif
...
@@ -119,6 +121,16 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
...
@@ -119,6 +121,16 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
#ifndef __mobile__
//-- Test for another instance already running. If that's the case, we simply exit.
QHostAddress
host
(
"127.0.0.1"
);
QUdpSocket
socket
;
if
(
!
socket
.
bind
(
host
,
SINGLE_INSTANCE_PORT
,
QAbstractSocket
::
DontShareAddress
))
{
qWarning
()
<<
"Another instance already running. Exiting."
;
exit
(
-
1
);
}
#endif
#ifdef Q_OS_MAC
#ifdef Q_OS_MAC
#ifndef __ios__
#ifndef __ios__
// Prevent Apple's app nap from screwing us over
// Prevent Apple's app nap from screwing us over
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment