From: José Fonseca Date: Mon, 10 Dec 2012 22:58:18 +0000 (+0000) Subject: Merge remote-tracking branch 'github/timestamp' X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=4f74cc67dd2b46d2abc0be5663c992410420091b;hp=4cc4c483e889a239c784f26ee461dad58db732a1 Merge remote-tracking branch 'github/timestamp' --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e31cb54..549d066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,19 +268,6 @@ endif () 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 diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index a01d3ae..e5ad36d 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -1,3 +1,14 @@ +# 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 diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp index 6a8ebe2..a69ce2f 100644 --- a/gui/apitrace.cpp +++ b/gui/apitrace.cpp @@ -393,6 +393,9 @@ void ApiTrace::loaderSearchResult(const ApiTrace::SearchRequest &request, void ApiTrace::findFrameStart(ApiTraceFrame *frame) { + if (!frame) + return; + if (frame->isLoaded()) { emit foundFrameStart(frame); } else { @@ -402,6 +405,9 @@ void ApiTrace::findFrameStart(ApiTraceFrame *frame) void ApiTrace::findFrameEnd(ApiTraceFrame *frame) { + if (!frame) + return; + if (frame->isLoaded()) { emit foundFrameEnd(frame); } else { diff --git a/gui/graphing/histogramview.cpp b/gui/graphing/histogramview.cpp index 0b94577..2dd3d8e 100644 --- a/gui/graphing/histogramview.cpp +++ b/gui/graphing/histogramview.cpp @@ -228,8 +228,8 @@ void HistogramView::paintEvent(QPaintEvent *) 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; diff --git a/gui/main.cpp b/gui/main.cpp index 0ed50ed..471dec7 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -3,6 +3,9 @@ #include "apitrace.h" #include "apitracecall.h" +#include "os_string.hpp" +#include "os_process.hpp" + #include #include #include @@ -32,6 +35,15 @@ int main(int argc, char **argv) qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType >(); + +#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; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index caf9e37..d6ebd2f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -48,6 +48,7 @@ MainWindow::MainWindow() m_nonDefaultsLookupEvent(0) { m_ui.setupUi(this); + updateActionsState(false); initObjects(); initConnections(); } @@ -228,11 +229,7 @@ void MainWindow::replayProfile() 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) @@ -243,18 +240,11 @@ 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())); } @@ -262,12 +252,7 @@ void MainWindow::newTraceFile(const QString &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; @@ -280,11 +265,7 @@ void MainWindow::replayFinished(const QString &message) 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; @@ -936,6 +917,47 @@ void MainWindow::initConnections() 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(); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 2248127..78267ef 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -98,6 +98,7 @@ private slots: 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(); diff --git a/gui/retracer.cpp b/gui/retracer.cpp index 738367e..2928ed6 100644 --- a/gui/retracer.cpp +++ b/gui/retracer.cpp @@ -137,19 +137,6 @@ Retracer::Retracer(QObject *parent) m_profilePixels(false) { qRegisterMetaType >(); - -#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 diff --git a/gui/retracer.h b/gui/retracer.h index e889d88..af1a3d9 100644 --- a/gui/retracer.h +++ b/gui/retracer.h @@ -65,8 +65,6 @@ private: bool m_profileGpu; bool m_profileCpu; bool m_profilePixels; - - QProcessEnvironment m_processEnvironment; }; #endif diff --git a/gui/tracedialog.cpp b/gui/tracedialog.cpp index fcfdf46..b8e438d 100644 --- a/gui/tracedialog.cpp +++ b/gui/tracedialog.cpp @@ -50,7 +50,7 @@ void TraceDialog::browse() tr("Find the application"), QDir::currentPath()); - if (isFileOk(fileName)) { + if (!fileName.isEmpty() && isFileOk(fileName)) { applicationEdit->setText(fileName); } } diff --git a/gui/traceprocess.cpp b/gui/traceprocess.cpp index 6f4d0b9..8d57e52 100644 --- a/gui/traceprocess.cpp +++ b/gui/traceprocess.cpp @@ -15,16 +15,6 @@ TraceProcess::TraceProcess(QObject *parent) 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() diff --git a/gui/trimprocess.cpp b/gui/trimprocess.cpp index c23475d..34639c6 100644 --- a/gui/trimprocess.cpp +++ b/gui/trimprocess.cpp @@ -15,16 +15,6 @@ TrimProcess::TrimProcess(QObject *parent) 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() diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index 7cbb3d1..06f4503 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -124,7 +124,7 @@ 0 - + about:blank @@ -493,9 +493,6 @@ - - false - :/resources/media-playback-start.png:/resources/media-playback-start.png @@ -508,9 +505,6 @@ - - false - :/resources/media-playback-stop.png:/resources/media-playback-stop.png @@ -520,9 +514,6 @@ - - false - :/resources/media-record.png:/resources/media-record.png @@ -535,9 +526,6 @@ - - false - Show &Thumbnails @@ -546,9 +534,6 @@ - - false - Tr&im @@ -567,7 +552,10 @@ :/resources/document-new.png:/resources/document-new.png - New + &New... + + + Ctrl+N @@ -576,7 +564,7 @@ :/resources/edit-find.png:/resources/edit-find.png - Find + &Find Ctrl+F @@ -638,9 +626,6 @@ - - false - &Profile diff --git a/gui/ui/tracedialog.ui b/gui/ui/tracedialog.ui index a3e5240..f6eccf4 100644 --- a/gui/ui/tracedialog.ui +++ b/gui/ui/tracedialog.ui @@ -47,7 +47,7 @@ - Browse + Browse... false