set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
-# Expose the binary/install directories to source
-#
-# TODO: Use the same directory layout, for both build and install directories,
-# so that binaries can find each other using just relative paths.
-#
-add_definitions(
- -DAPITRACE_BINARY_DIR="${CMAKE_BINARY_DIR}"
- -DAPITRACE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
- -DAPITRACE_PROGRAMS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/bin"
- -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
- -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
-)
-
##############################################################################
# Common libraries / utilities
+# Expose the binary/install directories to source
+#
+# TODO: Use the same directory layout, for both build and install directories,
+# so that binaries can find each other using just relative paths.
+#
+add_definitions(
+ -DAPITRACE_PROGRAMS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/bin"
+ -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
+ -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
+)
+
add_executable (apitrace
cli_main.cpp
cli_diff.cpp
void ApiTrace::findFrameStart(ApiTraceFrame *frame)
{
+ if (!frame)
+ return;
+
if (frame->isLoaded()) {
emit foundFrameStart(frame);
} else {
void ApiTrace::findFrameEnd(ApiTraceFrame *frame)
{
+ if (!frame)
+ return;
+
if (frame->isLoaded()) {
emit foundFrameEnd(frame);
} else {
qint64 HistogramView::itemAtPosition(QPoint pos) {
double dvdx = m_viewWidth / (double)width();
- qint64 left = qFloor(dvdx) * (pos.x() - 1) + m_viewLeft;
- qint64 right = qCeil(dvdx) * (pos.x() + 1) + m_viewLeft;
+ qint64 left = qFloor(dvdx * (pos.x() - 1)) + m_viewLeft;
+ qint64 right = qCeil(dvdx * (pos.x() + 1)) + m_viewLeft;
qint64 longestIndex = 0;
qint64 longestValue = 0;
#include "apitrace.h"
#include "apitracecall.h"
+#include "os_string.hpp"
+#include "os_process.hpp"
+
#include <QApplication>
#include <QMetaType>
#include <QVariant>
qRegisterMetaType<ApiTrace::SearchResult>();
qRegisterMetaType<ApiTrace::SearchRequest>();
qRegisterMetaType<QList<QImage> >();
+
+#ifndef Q_OS_WIN
+ os::String currentProcess = os::getProcessName();
+ currentProcess.trimFilename();
+ QString path = qgetenv("PATH");
+ path = QLatin1String(currentProcess.str()) + QLatin1String(":") + path;
+ qputenv("PATH", path.toLatin1());
+#endif
+
QStringList args = app.arguments();
int i = 1;
m_nonDefaultsLookupEvent(0)
{
m_ui.setupUi(this);
+ updateActionsState(false);
initObjects();
initConnections();
}
void MainWindow::replayStop()
{
m_retracer->quit();
- m_ui.actionStop->setEnabled(false);
- m_ui.actionReplay->setEnabled(true);
- m_ui.actionProfile->setEnabled(true);
- m_ui.actionLookupState->setEnabled(true);
- m_ui.actionShowThumbnails->setEnabled(true);
+ updateActionsState(true, true);
}
void MainWindow::newTraceFile(const QString &fileName)
m_trace->setFileName(fileName);
if (fileName.isEmpty()) {
- m_ui.actionReplay->setEnabled(false);
- m_ui.actionProfile->setEnabled(false);
- m_ui.actionLookupState->setEnabled(false);
- m_ui.actionShowThumbnails->setEnabled(false);
+ updateActionsState(false);
setWindowTitle(tr("QApiTrace"));
} else {
+ updateActionsState(true);
QFileInfo info(fileName);
- m_ui.actionReplay->setEnabled(true);
- m_ui.actionProfile->setEnabled(true);
- m_ui.actionLookupState->setEnabled(true);
- m_ui.actionShowThumbnails->setEnabled(true);
- m_ui.actionTrim->setEnabled(true);
setWindowTitle(
tr("QApiTrace - %1").arg(info.fileName()));
}
void MainWindow::replayFinished(const QString &message)
{
- m_ui.actionStop->setEnabled(false);
- m_ui.actionReplay->setEnabled(true);
- m_ui.actionProfile->setEnabled(true);
- m_ui.actionLookupState->setEnabled(true);
- m_ui.actionShowThumbnails->setEnabled(true);
-
+ updateActionsState(true);
m_progressBar->hide();
statusBar()->showMessage(message, 2000);
m_stateEvent = 0;
void MainWindow::replayError(const QString &message)
{
- m_ui.actionStop->setEnabled(false);
- m_ui.actionReplay->setEnabled(true);
- m_ui.actionProfile->setEnabled(true);
- m_ui.actionLookupState->setEnabled(true);
- m_ui.actionShowThumbnails->setEnabled(true);
+ updateActionsState(true);
m_stateEvent = 0;
m_nonDefaultsLookupEvent = 0;
this, SLOT(slotJumpTo(int)));
}
+void MainWindow::updateActionsState(bool traceLoaded, bool stopped)
+{
+ if (traceLoaded) {
+ /* Edit */
+ m_ui.actionFind ->setEnabled(true);
+ m_ui.actionGo ->setEnabled(true);
+ m_ui.actionGoFrameStart ->setEnabled(true);
+ m_ui.actionGoFrameEnd ->setEnabled(true);
+
+ /* Trace */
+ if (stopped) {
+ m_ui.actionStop->setEnabled(false);
+ m_ui.actionReplay->setEnabled(true);
+ }
+ else {
+ m_ui.actionStop->setEnabled(true);
+ m_ui.actionReplay->setEnabled(false);
+ }
+
+ m_ui.actionProfile ->setEnabled(true);
+ m_ui.actionLookupState ->setEnabled(true);
+ m_ui.actionShowThumbnails->setEnabled(true);
+ m_ui.actionTrim ->setEnabled(true);
+ }
+ else {
+ /* Edit */
+ m_ui.actionFind ->setEnabled(false);
+ m_ui.actionGo ->setEnabled(false);
+ m_ui.actionGoFrameStart ->setEnabled(false);
+ m_ui.actionGoFrameEnd ->setEnabled(false);
+
+ /* Trace */
+ m_ui.actionReplay ->setEnabled(false);
+ m_ui.actionProfile ->setEnabled(false);
+ m_ui.actionStop ->setEnabled(false);
+ m_ui.actionLookupState ->setEnabled(false);
+ m_ui.actionShowThumbnails->setEnabled(false);
+ m_ui.actionTrim ->setEnabled(false);
+ }
+}
+
void MainWindow::closeEvent(QCloseEvent * event)
{
m_profileDialog->close();
private:
void initObjects();
void initConnections();
+ void updateActionsState(bool traceLoaded, bool stopped = true);
void newTraceFile(const QString &fileName);
void replayTrace(bool dumpState, bool dumpThumbnails);
void trimEvent();
m_profilePixels(false)
{
qRegisterMetaType<QList<ApiTraceError> >();
-
-#ifdef Q_OS_WIN
- QString format = QLatin1String("%1;");
-#else
- QString format = QLatin1String("%1:");
-#endif
- QString buildPath = format.arg(APITRACE_BINARY_DIR);
- m_processEnvironment = QProcessEnvironment::systemEnvironment();
- m_processEnvironment.insert("PATH", buildPath +
- m_processEnvironment.value("PATH"));
-
- qputenv("PATH",
- m_processEnvironment.value("PATH").toLatin1());
}
QString Retracer::fileName() const
bool m_profileGpu;
bool m_profileCpu;
bool m_profilePixels;
-
- QProcessEnvironment m_processEnvironment;
};
#endif
tr("Find the application"),
QDir::currentPath());
- if (isFileOk(fileName)) {
+ if (!fileName.isEmpty() && isFileOk(fileName)) {
applicationEdit->setText(fileName);
}
}
this, SLOT(traceFinished()));
connect(m_process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(traceError(QProcess::ProcessError)));
-
-#ifdef Q_OS_WIN
- QString format = QLatin1String("%1;");
-#else
- QString format = QLatin1String("%1:");
-#endif
- QString buildPath = format.arg(APITRACE_BINARY_DIR);
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- env.insert("PATH", buildPath + env.value("PATH"));
- qputenv("PATH", env.value("PATH").toLatin1());
}
TraceProcess::~TraceProcess()
this, SLOT(trimFinished()));
connect(m_process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(trimError(QProcess::ProcessError)));
-
-#ifdef Q_OS_WIN
- QString format = QLatin1String("%1;");
-#else
- QString format = QLatin1String("%1:");
-#endif
- QString buildPath = format.arg(APITRACE_BINARY_DIR);
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- env.insert("PATH", buildPath + env.value("PATH"));
- qputenv("PATH", env.value("PATH").toLatin1());
}
TrimProcess::~TrimProcess()
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="url" stdset="0">
+ <property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</action>
<action name="actionReplay">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/media-playback-start.png</normaloff>:/resources/media-playback-start.png</iconset>
</property>
</action>
<action name="actionStop">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/media-playback-stop.png</normaloff>:/resources/media-playback-stop.png</iconset>
</property>
</action>
<action name="actionLookupState">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/media-record.png</normaloff>:/resources/media-record.png</iconset>
</property>
</action>
<action name="actionShowThumbnails">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>Show &Thumbnails</string>
</property>
</property>
</action>
<action name="actionTrim">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>Tr&im</string>
</property>
<normaloff>:/resources/document-new.png</normaloff>:/resources/document-new.png</iconset>
</property>
<property name="text">
- <string>New</string>
+ <string>&New...</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
</property>
</action>
<action name="actionFind">
<normaloff>:/resources/edit-find.png</normaloff>:/resources/edit-find.png</iconset>
</property>
<property name="text">
- <string>Find</string>
+ <string>&Find</string>
</property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
</action>
<action name="actionProfile">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>&Profile</string>
</property>
<item>
<widget class="QPushButton" name="browseButton">
<property name="text">
- <string>Browse</string>
+ <string>Browse...</string>
</property>
<property name="flat">
<bool>false</bool>