Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
35493c45
Commit
35493c45
authored
Apr 14, 2011
by
Kai Koehne
Browse files
QmlProfiler: Use ApplicationLauncher instead of QProcess
parent
20cb599b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmlprofiler/qmlprofilerengine.cpp
View file @
35493c45
...
...
@@ -38,6 +38,7 @@
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerconstants.h>
#include <projectexplorer/applicationlauncher.h>
#include <qmljsdebugclient/qdeclarativedebugclient_p.h>
...
...
@@ -50,7 +51,6 @@
#include "canvas/qdeclarativecontext2d_p.h"
#include "canvas/qdeclarativetiledcanvas_p.h"
#include <QProcess>
using
namespace
QmlProfiler
::
Internal
;
...
...
@@ -61,13 +61,13 @@ public:
QmlProfilerEnginePrivate
(
QmlProfilerEngine
*
qq
)
:
q
(
qq
)
{}
~
QmlProfilerEnginePrivate
()
{}
bool
launchperfmonitor
();
void
launchperfmonitor
();
bool
attach
(
const
QString
&
address
,
uint
port
);
QmlProfilerEngine
*
q
;
Analyzer
::
AnalyzerStartParameters
m_params
;
Q
Pro
cess
*
m_process
;
Pro
jectExplorer
::
ApplicationLauncher
m_launcher
;
bool
m_running
;
bool
m_fetchingData
;
bool
m_delayedDelete
;
...
...
@@ -78,10 +78,13 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
,
d
(
new
QmlProfilerEnginePrivate
(
this
))
{
d
->
m_params
=
sp
;
d
->
m_process
=
0
;
d
->
m_running
=
false
;
d
->
m_fetchingData
=
false
;
d
->
m_delayedDelete
=
false
;
connect
(
&
d
->
m_launcher
,
SIGNAL
(
appendMessage
(
QString
,
ProjectExplorer
::
OutputFormat
)),
this
,
SLOT
(
logApplicationMessage
(
QString
,
ProjectExplorer
::
OutputFormat
)));
}
QmlProfilerEngine
::~
QmlProfilerEngine
()
...
...
@@ -111,8 +114,10 @@ void QmlProfilerEngine::stop()
finishProcess
();
}
void
QmlProfilerEngine
::
spontaneousStop
()
void
QmlProfilerEngine
::
spontaneousStop
(
int
exitCode
)
{
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
()
<<
"QmlProfiler: Application exited (exit code "
<<
exitCode
<<
")."
;
d
->
m_running
=
false
;
Analyzer
::
AnalyzerManager
::
instance
()
->
stopTool
();
emit
finished
();
...
...
@@ -131,74 +136,34 @@ void QmlProfilerEngine::dataReceived() {
void
QmlProfilerEngine
::
finishProcess
()
{
// user stop?
if
(
d
->
m_running
)
{
d
->
m_running
=
false
;
if
(
d
->
m_process
)
{
disconnect
(
d
->
m_process
,
SIGNAL
(
finished
(
int
)),
this
,
SLOT
(
spontaneousStop
()));
if
(
d
->
m_process
->
state
()
==
QProcess
::
Running
)
{
d
->
m_process
->
terminate
();
if
(
!
d
->
m_process
->
waitForFinished
(
1000
))
{
d
->
m_process
->
kill
();
d
->
m_process
->
waitForFinished
();
}
}
delete
d
->
m_process
;
d
->
m_process
=
0
;
disconnect
(
&
d
->
m_launcher
,
SIGNAL
(
processExited
(
int
)),
this
,
SLOT
(
spontaneousStop
()));
if
(
d
->
m_launcher
.
isRunning
())
{
d
->
m_launcher
.
stop
();
}
emit
finished
();
}
}
bool
QmlProfilerEngine
::
QmlProfilerEnginePrivate
::
launchperfmonitor
()
void
QmlProfilerEngine
::
QmlProfilerEnginePrivate
::
launchperfmonitor
()
{
bool
qtquick1
=
false
;
m_process
=
new
QProcess
();
QStringList
arguments
(
"-qmljsdebugger=port:"
+
QString
::
number
(
m_params
.
connParams
.
port
)
+
",block"
);
arguments
.
append
(
m_params
.
debuggeeArgs
.
split
(
" "
));
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
(
"QmlProfiler: Launching %s"
,
qPrintable
(
m_params
.
displayName
));
if
(
qtquick1
)
{
QProcessEnvironment
env
;
env
.
insert
(
"QMLSCENE_IMPORT_NAME"
,
"quick1"
);
m_process
->
setProcessEnvironment
(
env
);
}
m_process
->
setProcessChannelMode
(
QProcess
::
ForwardedChannels
);
m_process
->
setWorkingDirectory
(
m_params
.
workingDirectory
);
connect
(
m_process
,
SIGNAL
(
finished
(
int
)),
q
,
SLOT
(
spontaneousStop
()));
m_process
->
start
(
m_params
.
debuggee
,
arguments
);
if
(
!
m_process
->
waitForStarted
())
{
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
(
"QmlProfiler: %s failed to start"
,
qPrintable
(
m_params
.
displayName
));
return
false
;
}
QString
arguments
=
m_params
.
debuggeeArgs
;
arguments
+=
QLatin1String
(
"-qmljsdebugger=port:"
)
+
QString
::
number
(
m_params
.
connParams
.
port
)
+
QLatin1String
(
",block"
);
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
(
"QmlProfiler:
Connecting to
%s:%d"
,
qPrintable
(
m_params
.
connParams
.
host
),
m_params
.
connParams
.
port
);
qWarning
(
"QmlProfiler:
Launching
%s:%d"
,
qPrintable
(
m_params
.
displayName
),
m_params
.
connParams
.
port
);
return
true
;
m_launcher
.
setWorkingDirectory
(
m_params
.
workingDirectory
);
m_launcher
.
setEnvironment
(
m_params
.
environment
);
connect
(
&
m_launcher
,
SIGNAL
(
processExited
(
int
)),
q
,
SLOT
(
spontaneousStop
(
int
)));
m_launcher
.
start
(
ProjectExplorer
::
ApplicationLauncher
::
Gui
,
m_params
.
debuggee
,
arguments
);
}
void
QmlProfilerEngine
::
logApplicationMessage
(
const
QString
&
msg
,
ProjectExplorer
::
OutputFormat
/*format*/
)
{
qDebug
()
<<
"app: "
<<
msg
;
}
src/plugins/qmlprofiler/qmlprofilerengine.h
View file @
35493c45
...
...
@@ -35,6 +35,7 @@
#define QMLPROFILERENGINE_H
#include <analyzerbase/ianalyzerengine.h>
#include <projectexplorer/outputformat.h>
namespace
QmlProfiler
{
namespace
Internal
{
...
...
@@ -55,11 +56,14 @@ signals:
public
slots
:
void
start
();
void
stop
();
void
spontaneousStop
();
private
slots
:
void
spontaneousStop
(
int
exitCode
);
void
setFetchingData
(
bool
);
void
dataReceived
();
void
finishProcess
();
void
logApplicationMessage
(
const
QString
&
msg
,
ProjectExplorer
::
OutputFormat
format
);
private:
class
QmlProfilerEnginePrivate
;
...
...
Write
Preview
Supports
Markdown
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