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
6d174080
Commit
6d174080
authored
May 04, 2011
by
Kai Koehne
Browse files
QmlProfiler: Factor out logic to run apps from the engine into a separate runner
Reviewed-by: Christiaan Janssen
parent
7b41c76d
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmlprofiler/abstractqmlprofilerrunner.h
0 → 100644
View file @
6d174080
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ABSTRACTQMLPROFILERRUNNER_H
#define ABSTRACTQMLPROFILERRUNNER_H
#include <QtCore/QObject>
#include <utils/outputformat.h>
namespace
QmlProfiler
{
namespace
Internal
{
class
AbstractQmlProfilerRunner
:
public
QObject
{
Q_OBJECT
public:
explicit
AbstractQmlProfilerRunner
(
QObject
*
parent
=
0
)
:
QObject
(
parent
)
{
}
virtual
void
start
()
=
0
;
virtual
void
stop
()
=
0
;
signals:
void
started
();
void
stopped
();
void
appendMessage
(
const
QString
&
message
,
Utils
::
OutputFormat
format
);
};
}
// namespace Internal
}
// namespace QmlProfiler
#endif // ABSTRACTQMLPROFILERRUNNER_H
src/plugins/qmlprofiler/localqmlprofilerrunner.cpp
0 → 100644
View file @
6d174080
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "localqmlprofilerrunner.h"
#include "qmlprofilerplugin.h"
using
namespace
QmlProfiler
;
using
namespace
QmlProfiler
::
Internal
;
LocalQmlProfilerRunner
::
LocalQmlProfilerRunner
(
const
Configuration
&
configuration
,
QObject
*
parent
)
:
AbstractQmlProfilerRunner
(
parent
),
m_configuration
(
configuration
)
{
connect
(
&
m_launcher
,
SIGNAL
(
appendMessage
(
QString
,
Utils
::
OutputFormat
)),
this
,
SIGNAL
(
appendMessage
(
QString
,
Utils
::
OutputFormat
)));
}
void
LocalQmlProfilerRunner
::
start
()
{
QString
arguments
=
QString
(
"-qmljsdebugger=port:%1,block"
).
arg
(
QString
::
number
(
m_configuration
.
port
));
if
(
!
m_configuration
.
executableArguments
.
isEmpty
())
arguments
+=
QChar
(
' '
)
+
m_configuration
.
executableArguments
;
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
(
"QmlProfiler: Launching %s:%d"
,
qPrintable
(
m_configuration
.
executable
),
m_configuration
.
port
);
m_launcher
.
setWorkingDirectory
(
m_configuration
.
workingDirectory
);
m_launcher
.
setEnvironment
(
m_configuration
.
environment
);
connect
(
&
m_launcher
,
SIGNAL
(
processExited
(
int
)),
this
,
SLOT
(
spontaneousStop
(
int
)));
m_launcher
.
start
(
ProjectExplorer
::
ApplicationLauncher
::
Gui
,
m_configuration
.
executable
,
arguments
);
emit
started
();
}
void
LocalQmlProfilerRunner
::
spontaneousStop
(
int
exitCode
)
{
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
()
<<
"QmlProfiler: Application exited (exit code"
<<
exitCode
<<
")."
;
disconnect
(
&
m_launcher
,
SIGNAL
(
processExited
(
int
)),
this
,
SLOT
(
spontaneousStop
(
int
)));
emit
stopped
();
}
void
LocalQmlProfilerRunner
::
stop
()
{
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
()
<<
"QmlProfiler: Stopping application ..."
;
if
(
m_launcher
.
isRunning
())
{
m_launcher
.
stop
();
}
}
src/plugins/qmlprofiler/localqmlprofilerrunner.h
0 → 100644
View file @
6d174080
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef LOCALQMLPROFILERRUNNER_H
#define LOCALQMLPROFILERRUNNER_H
#include "abstractqmlprofilerrunner.h"
#include <utils/environment.h>
#include <projectexplorer/applicationlauncher.h>
namespace
QmlProfiler
{
namespace
Internal
{
class
LocalQmlProfilerRunner
:
public
AbstractQmlProfilerRunner
{
Q_OBJECT
Q_DISABLE_COPY
(
LocalQmlProfilerRunner
)
public:
struct
Configuration
{
QString
executable
;
QString
executableArguments
;
quint16
port
;
QString
workingDirectory
;
Utils
::
Environment
environment
;
};
explicit
LocalQmlProfilerRunner
(
const
Configuration
&
configuration
,
QObject
*
parent
=
0
);
// AbstractQmlProfilerRunner
virtual
void
start
();
virtual
void
stop
();
private
slots
:
void
spontaneousStop
(
int
exitCode
);
private:
Configuration
m_configuration
;
ProjectExplorer
::
ApplicationLauncher
m_launcher
;
};
}
// namespace Internal
}
// namespace QmlProfiler
#endif // LOCALQMLPROFILERRUNNER_H
src/plugins/qmlprofiler/qmlprofiler.pro
View file @
6d174080
...
...
@@ -21,7 +21,8 @@ SOURCES += \
timelineview
.
cpp
\
qmlprofilerattachdialog
.
cpp
\
qmlprofilersummaryview
.
cpp
\
qmlprojectanalyzerruncontrolfactory
.
cpp
qmlprojectanalyzerruncontrolfactory
.
cpp
\
localqmlprofilerrunner
.
cpp
HEADERS
+=
\
qmlprofilerconstants
.
h
\
...
...
@@ -33,7 +34,9 @@ HEADERS += \
timelineview
.
h
\
qmlprofilerattachdialog
.
h
\
qmlprofilersummaryview
.
h
\
qmlprojectanalyzerruncontrolfactory
.
h
qmlprojectanalyzerruncontrolfactory
.
h
\
abstractqmlprofilerrunner
.
h
\
localqmlprofilerrunner
.
h
RESOURCES
+=
\
qml
/
qml
.
qrc
...
...
src/plugins/qmlprofiler/qmlprofilerengine.cpp
View file @
6d174080
...
...
@@ -35,6 +35,7 @@
#include "qmlprofilerplugin.h"
#include "qmlprofilertool.h"
#include "localqmlprofilerrunner.h"
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerconstants.h>
...
...
@@ -42,6 +43,8 @@
#include <qmljsdebugclient/qdeclarativedebugclient_p.h>
#include <utils/qtcassert.h>
#include "timelineview.h"
#include "tracewindow.h"
...
...
@@ -55,24 +58,53 @@
using
namespace
QmlProfiler
::
Internal
;
//
// QmlProfilerEnginePrivate
//
class
QmlProfilerEngine
::
QmlProfilerEnginePrivate
{
public:
QmlProfilerEnginePrivate
(
QmlProfilerEngine
*
qq
)
:
q
(
qq
)
{}
QmlProfilerEnginePrivate
(
QmlProfilerEngine
*
qq
)
:
q
(
qq
)
,
m_runner
(
0
)
{}
~
QmlProfilerEnginePrivate
()
{}
void
launchperfmonitor
();
bool
attach
(
const
QString
&
address
,
uint
port
);
static
AbstractQmlProfilerRunner
*
createRunner
(
const
Analyzer
::
AnalyzerStartParameters
&
m_params
,
QObject
*
parent
);
QmlProfilerEngine
*
q
;
Analyzer
::
AnalyzerStartParameters
m_params
;
ProjectExplorer
::
ApplicationLaunch
er
m_
launch
er
;
AbstractQmlProfilerRunn
er
*
m_
runn
er
;
bool
m_running
;
bool
m_fetchingData
;
bool
m_delayedDelete
;
};
AbstractQmlProfilerRunner
*
QmlProfilerEngine
::
QmlProfilerEnginePrivate
::
createRunner
(
const
Analyzer
::
AnalyzerStartParameters
&
m_params
,
QObject
*
parent
)
{
AbstractQmlProfilerRunner
*
runner
=
0
;
if
(
m_params
.
startMode
==
Analyzer
::
StartLocal
)
{
LocalQmlProfilerRunner
::
Configuration
configuration
;
configuration
.
executable
=
m_params
.
debuggee
;
configuration
.
executableArguments
=
m_params
.
debuggeeArgs
;
configuration
.
workingDirectory
=
m_params
.
workingDirectory
;
configuration
.
environment
=
m_params
.
environment
;
configuration
.
port
=
m_params
.
connParams
.
port
;
runner
=
new
LocalQmlProfilerRunner
(
configuration
,
parent
);
}
else
if
(
m_params
.
startMode
==
Analyzer
::
StartRemote
)
{
}
return
runner
;
}
//
// QmlProfilerEngine
//
QmlProfilerEngine
::
QmlProfilerEngine
(
const
Analyzer
::
AnalyzerStartParameters
&
sp
,
ProjectExplorer
::
RunConfiguration
*
runConfiguration
)
:
IAnalyzerEngine
(
sp
,
runConfiguration
)
,
d
(
new
QmlProfilerEnginePrivate
(
this
))
...
...
@@ -82,9 +114,6 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
d
->
m_running
=
false
;
d
->
m_fetchingData
=
false
;
d
->
m_delayedDelete
=
false
;
connect
(
&
d
->
m_launcher
,
SIGNAL
(
appendMessage
(
QString
,
Utils
::
OutputFormat
)),
this
,
SLOT
(
logApplicationMessage
(
QString
,
Utils
::
OutputFormat
)));
}
QmlProfilerEngine
::~
QmlProfilerEngine
()
...
...
@@ -96,11 +125,19 @@ QmlProfilerEngine::~QmlProfilerEngine()
void
QmlProfilerEngine
::
start
()
{
d
->
launchperfmonitor
();
QTC_ASSERT
(
!
d
->
m_runner
,
return
);
d
->
m_runner
=
QmlProfilerEnginePrivate
::
createRunner
(
d
->
m_params
,
this
);
QTC_ASSERT
(
d
->
m_runner
,
return
);
connect
(
d
->
m_runner
,
SIGNAL
(
started
()),
this
,
SIGNAL
(
processRunning
()));
connect
(
d
->
m_runner
,
SIGNAL
(
stopped
()),
this
,
SLOT
(
stopped
()));
connect
(
d
->
m_runner
,
SIGNAL
(
appendMessage
(
QString
,
Utils
::
OutputFormat
)),
this
,
SLOT
(
logApplicationMessage
(
QString
,
Utils
::
OutputFormat
)));
d
->
m_runner
->
start
();
d
->
m_running
=
true
;
d
->
m_delayedDelete
=
false
;
emit
processRunning
();
}
void
QmlProfilerEngine
::
stop
()
...
...
@@ -109,15 +146,13 @@ void QmlProfilerEngine::stop()
if
(
d
->
m_running
)
d
->
m_delayedDelete
=
true
;
emit
stopRecording
();
}
else
}
else
{
finishProcess
();
}
}
void
QmlProfilerEngine
::
s
pontaneousStop
(
int
exitCode
)
void
QmlProfilerEngine
::
s
topped
(
)
{
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
()
<<
"QmlProfiler: Application exited (exit code "
<<
exitCode
<<
")."
;
d
->
m_running
=
false
;
Analyzer
::
AnalyzerManager
::
instance
()
->
stopTool
();
emit
finished
();
...
...
@@ -139,31 +174,12 @@ void QmlProfilerEngine::finishProcess()
// user stop?
if
(
d
->
m_running
)
{
d
->
m_running
=
false
;
disconnect
(
&
d
->
m_launcher
,
SIGNAL
(
processExited
(
int
)),
this
,
SLOT
(
spontaneousStop
(
int
)));
if
(
d
->
m_launcher
.
isRunning
())
{
d
->
m_launcher
.
stop
();
}
d
->
m_runner
->
stop
();
emit
finished
();
}
}
void
QmlProfilerEngine
::
QmlProfilerEnginePrivate
::
launchperfmonitor
()
{
QString
arguments
=
QLatin1String
(
"-qmljsdebugger=port:"
)
+
QString
::
number
(
m_params
.
connParams
.
port
)
+
QLatin1String
(
",block"
);
if
(
!
m_params
.
debuggeeArgs
.
isEmpty
())
arguments
+=
QChar
(
' '
)
+
m_params
.
debuggeeArgs
;
if
(
QmlProfilerPlugin
::
debugOutput
)
qWarning
(
"QmlProfiler: Launching %s:%d"
,
qPrintable
(
m_params
.
displayName
),
m_params
.
connParams
.
port
);
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
,
Utils
::
OutputFormat
/*format*/
)
{
qDebug
()
<<
"app: "
<<
msg
;
...
...
src/plugins/qmlprofiler/qmlprofilerengine.h
View file @
6d174080
...
...
@@ -50,7 +50,6 @@ public:
signals:
void
processRunning
();
//void finished();
void
stopRecording
();
public
slots
:
...
...
@@ -58,7 +57,7 @@ public slots:
void
stop
();
private
slots
:
void
s
pontaneousStop
(
int
exitCode
);
void
s
topped
(
);
void
setFetchingData
(
bool
);
void
dataReceived
();
...
...
src/plugins/qmlprofiler/qmlprofilertool.cpp
View file @
6d174080
...
...
@@ -314,8 +314,10 @@ void QmlProfilerTool::disconnectClient()
{
// this might be actually be called indirectly by QDDConnectionPrivate::readyRead(), therefore allow
// method to complete before deleting object
d
->
m_client
->
deleteLater
();
d
->
m_client
=
0
;
if
(
d
->
m_client
)
{
d
->
m_client
->
deleteLater
();
d
->
m_client
=
0
;
}
}
void
QmlProfilerTool
::
startRecording
()
...
...
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