@@ -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}
0 commit comments