Skip to content

Commit 0639eb6

Browse files
committed
Perl debugger GUI update
1 parent 2613f1d commit 0639eb6

File tree

2 files changed

+69
-57
lines changed

2 files changed

+69
-57
lines changed

src/perl-debugger-handler.cpp

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,61 +33,71 @@ QPerlDebuggerHandler::QPerlDebuggerHandler()
3333
selectScriptToDebugDialog
3434
.setWindowModality(Qt::WindowModal);
3535

36-
QString scriptToDebug = selectScriptToDebugDialog
37-
.getOpenFileName
38-
(qApp->activeWindow(), "Select Perl File",
39-
QDir::currentPath(), "Perl scripts (*.pl);;All files (*)");
36+
QString scriptToDebugFilePath =
37+
QDir::toNativeSeparators(selectScriptToDebugDialog
38+
.getOpenFileName
39+
(qApp->activeWindow(),
40+
"Select Perl File",
41+
QDir::currentPath(),
42+
"Perl scripts (*.pl);;All files (*)"));
4043

4144
selectScriptToDebugDialog.close();
4245
selectScriptToDebugDialog.deleteLater();
4346

44-
QString commandLineArguments;
47+
if (scriptToDebugFilePath.length() > 1) {
48+
QString browserScriptMarker =
49+
QString("resources") + QDir::separator() + QString("app");
50+
QString commandLineArguments;
4551

46-
if (scriptToDebug.length() > 1) {
47-
scriptToDebug = QDir::toNativeSeparators(scriptToDebug);
52+
// Get command-line arguments
53+
// if the debugged script is not a PEB-based Perl script
54+
if (!scriptToDebugFilePath.contains(browserScriptMarker)) {
55+
bool ok;
56+
QString input =
57+
QInputDialog::getText(
58+
qApp->activeWindow(),
59+
"Command Line",
60+
"Enter all command line arguments, if any:",
61+
QLineEdit::Normal,
62+
"",
63+
&ok);
4864

49-
// Get all command-line arguments for the debugged Perl script:
50-
bool ok;
51-
QString input =
52-
QInputDialog::getText(
53-
qApp->activeWindow(),
54-
"Command Line",
55-
"Enter all command line arguments, if any:",
56-
QLineEdit::Normal,
57-
"",
58-
&ok);
59-
60-
if (ok && !input.isEmpty()) {
61-
commandLineArguments = input;
65+
if (ok && !input.isEmpty()) {
66+
commandLineArguments = input;
67+
}
6268
}
6369

6470
qDebug() << QDateTime::currentMSecsSinceEpoch()
6571
<< "msecs from epoch: file passed to Perl debugger:"
66-
<< scriptToDebug;
67-
}
72+
<< scriptToDebugFilePath;
6873

69-
// Signal and slot for reading the Perl debugger output:
70-
QObject::connect(&debuggerHandler, SIGNAL(readyReadStandardOutput()),
71-
this, SLOT(qDebuggerOutputSlot()));
74+
// Signal and slot for reading the Perl debugger output:
75+
QObject::connect(&debuggerHandler, SIGNAL(readyReadStandardOutput()),
76+
this, SLOT(qDebuggerOutputSlot()));
7277

73-
// Sеt the environment for the debugged script:
74-
QProcessEnvironment systemEnvironment =
75-
QProcessEnvironment::systemEnvironment();
76-
systemEnvironment.insert("PERLDB_OPTS", "ReadLine=0");
77-
debuggerHandler.setProcessEnvironment(systemEnvironment);
78+
// Sеt the environment for the debugged script:
79+
QProcessEnvironment systemEnvironment =
80+
QProcessEnvironment::systemEnvironment();
81+
systemEnvironment.insert("PERLDB_OPTS", "ReadLine=0");
82+
debuggerHandler.setProcessEnvironment(systemEnvironment);
7883

79-
QFileInfo scriptAbsoluteFilePath(scriptToDebug);
80-
QString scriptDirectory = scriptAbsoluteFilePath.absolutePath();
81-
debuggerHandler.setWorkingDirectory(scriptDirectory);
84+
// Set the working directory to the script directory
85+
// if the debugged script is not a PEB-based Perl script
86+
if (!scriptToDebugFilePath.contains(browserScriptMarker)) {
87+
QFileInfo scriptAbsoluteFilePath(scriptToDebugFilePath);
88+
QString scriptDirectory = scriptAbsoluteFilePath.absolutePath();
89+
debuggerHandler.setWorkingDirectory(scriptDirectory);
90+
}
8291

83-
debuggerHandler.setProcessChannelMode(QProcess::MergedChannels);
92+
debuggerHandler.setProcessChannelMode(QProcess::MergedChannels);
8493

85-
debuggerHandler.start(qApp->property("perlInterpreter")
86-
.toString(),
87-
QStringList()
88-
<< "-d"
89-
<< scriptToDebug
90-
<< commandLineArguments,
91-
QProcess::Unbuffered
92-
| QProcess::ReadWrite);
94+
debuggerHandler.start(qApp->property("perlInterpreter")
95+
.toString(),
96+
QStringList()
97+
<< "-d"
98+
<< scriptToDebugFilePath
99+
<< commandLineArguments,
100+
QProcess::Unbuffered
101+
| QProcess::ReadWrite);
102+
}
93103
}

src/script-handler.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,24 @@ QScriptHandler::QScriptHandler(QUrl url, QByteArray postDataArray)
5454
scriptUser = url.userName();
5555

5656
if (scriptUser.length() > 0) {
57-
scriptId = url.password() + "@" + url.path();
58-
59-
scriptCloseCommand =
60-
scriptQuery.queryItemValue("close_command");
61-
if (scriptCloseCommand.length() == 0) {
62-
qDebug() << "Close command is not defined"
63-
<< "for interactive script:"
64-
<< scriptFullFilePath;
65-
}
57+
if (scriptUser == "interactive") {
58+
scriptId = url.password() + "@" + url.path();
59+
60+
scriptCloseCommand =
61+
scriptQuery.queryItemValue("close_command");
62+
if (scriptCloseCommand.length() == 0) {
63+
qDebug() << "Close command is not defined"
64+
<< "for interactive script:"
65+
<< scriptFullFilePath;
66+
}
6667

67-
scriptCloseConfirmation =
68-
scriptQuery.queryItemValue("close_confirmation");
69-
if (scriptCloseConfirmation.length() == 0) {
70-
qDebug() << "Close confirmation is not defined"
71-
<< "for interactive script:"
72-
<< scriptFullFilePath;
68+
scriptCloseConfirmation =
69+
scriptQuery.queryItemValue("close_confirmation");
70+
if (scriptCloseConfirmation.length() == 0) {
71+
qDebug() << "Close confirmation is not defined"
72+
<< "for interactive script:"
73+
<< scriptFullFilePath;
74+
}
7375
}
7476
}
7577

0 commit comments

Comments
 (0)