Skip to content

Commit 19e63a0

Browse files
committed
Remove argument from list in advance
Change-Id: I0ab91bce1f290f3a04f27e776eb88a2a385e87e8 Reviewed-by: Samuli Piippo <[email protected]>
1 parent bb952d2 commit 19e63a0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

main.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,35 +168,36 @@ int main(int argc, char **argv)
168168
Config config = parseConfigFile();
169169

170170
while (!args.isEmpty()) {
171-
if (args[0] == "--port-range") {
172-
if (args.size() < 2) {
173-
qWarning("--port-range requires a range specification");
171+
const QString arg(args.takeFirst());
172+
173+
if (arg == "--port-range") {
174+
if (args.isEmpty()) {
175+
fprintf(stderr, "--port-range requires a range specification\n");
174176
return 1;
175177
}
176-
range = Utils::PortList::fromString(args[1]);
177-
args.removeFirst();
178+
range = Utils::PortList::fromString(args.takeFirst());
178179
if (!range.hasMore()) {
179180
qWarning("Invalid port range");
180181
return 1;
181182
}
182-
} else if (args[0] == "--debug-gdb") {
183+
} else if (arg == "--debug-gdb") {
183184
useGDB = true;
184185
setpgid(0,0); // must be called before setsid()
185186
setsid();
186-
} else if (args[0] == "--debug-qml") {
187+
} else if (arg == "--debug-qml") {
187188
useQML = true;
188-
} else if (args[0] == "--stop") {
189+
} else if (arg == "--stop") {
189190
stop();
190191
return 0;
191-
} else if (args[0] == "--show-platform") {
192+
} else if (arg == "--show-platform") {
192193
printf("base:%s\nplatform:%s\n",
193194
config.base.toLocal8Bit().constData(),
194195
config.platform.toLocal8Bit().constData());
195196
return 0;
196197
} else {
198+
args.prepend(arg);
197199
break;
198200
}
199-
args.removeFirst();
200201
}
201202

202203
if (args.isEmpty()) {

0 commit comments

Comments
 (0)