]> git.cworth.org Git - apitrace/commitdiff
Merge remote-tracking branch 'github/timestamp'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 10 Dec 2012 22:58:18 +0000 (22:58 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 10 Dec 2012 22:58:18 +0000 (22:58 +0000)
14 files changed:
CMakeLists.txt
cli/CMakeLists.txt
gui/apitrace.cpp
gui/graphing/histogramview.cpp
gui/main.cpp
gui/mainwindow.cpp
gui/mainwindow.h
gui/retracer.cpp
gui/retracer.h
gui/tracedialog.cpp
gui/traceprocess.cpp
gui/trimprocess.cpp
gui/ui/mainwindow.ui
gui/ui/tracedialog.ui

index e31cb54fe51a1a7b522f252dd6a81b801098172f..549d0665c0c3110d22a16f873be39beb62201562 100644 (file)
@@ -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
index a01d3aed11e72b0da42276c3552e8935b525787c..e5ad36d990979e84e921bf9008d8b14d15489353 100644 (file)
@@ -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
index 6a8ebe2cd043a4608191db584f2b78274ba09143..a69ce2fff0ef25a2f0293e392e273f9b4ecc1b4d 100644 (file)
@@ -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 {
index 0b945772b96916bbe470289865eedcfba9e96b33..2dd3d8e94263b3cf95d5bff59b5381282ac8f0ab 100644 (file)
@@ -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;
index 0ed50ed8f2b33506f931f570d9662430d59712ec..471dec7939c7eccd88c4d1c882a121ea2a587b08 100644 (file)
@@ -3,6 +3,9 @@
 #include "apitrace.h"
 #include "apitracecall.h"
 
+#include "os_string.hpp"
+#include "os_process.hpp"
+
 #include <QApplication>
 #include <QMetaType>
 #include <QVariant>
@@ -32,6 +35,15 @@ int main(int argc, char **argv)
     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;
index caf9e370236ebed41d8aa29409cc3e253b1457a4..d6ebd2f9e1ecbe3a107222b684cda6c1e826c7e3 100644 (file)
@@ -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();
index 2248127f76aae57b8acd4728c7b090ad628564da..78267efca4c9f5cd98bb4eb0b48a5bc980ae3ceb 100644 (file)
@@ -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();
index 738367e1830c394f2808ab8a234355dd8de8e48a..2928ed63f321f31e34667e2448e1b8f765f2fdbf 100644 (file)
@@ -137,19 +137,6 @@ Retracer::Retracer(QObject *parent)
       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
index e889d8887cf3753ce609d86daefa6233d7134ddf..af1a3d9f7b727b70f1173dcc058980bba590f6a6 100644 (file)
@@ -65,8 +65,6 @@ private:
     bool m_profileGpu;
     bool m_profileCpu;
     bool m_profilePixels;
-
-    QProcessEnvironment m_processEnvironment;
 };
 
 #endif
index fcfdf4661241ff30858f0f5332d83fbd30bcc126..b8e438d9ddddc3c7fe49307f2b41de6778b47854 100644 (file)
@@ -50,7 +50,7 @@ void TraceDialog::browse()
             tr("Find the application"),
             QDir::currentPath());
 
-    if (isFileOk(fileName)) {
+    if (!fileName.isEmpty() && isFileOk(fileName)) {
         applicationEdit->setText(fileName);
     }
 }
index 6f4d0b9350da147249bbf1e522fd8c51d6de4384..8d57e525f0617b901a124369f1deb07da2c995a4 100644 (file)
@@ -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()
index c23475d50d86a62e078594f6786073628f4ebd9a..34639c634d4893ad55d38617ebc0a7307c9f53c7 100644 (file)
@@ -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()
index 7cbb3d1e3bea979532b80bd7bdbf620b80822d9a..06f4503af50d92cf3015ce7baaecb3aaed588252 100644 (file)
          <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 &amp;Thumbnails</string>
    </property>
    </property>
   </action>
   <action name="actionTrim">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="text">
     <string>Tr&amp;im</string>
    </property>
      <normaloff>:/resources/document-new.png</normaloff>:/resources/document-new.png</iconset>
    </property>
    <property name="text">
-    <string>New</string>
+    <string>&amp;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>&amp;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>&amp;Profile</string>
    </property>
index a3e5240a540b2ec44a2751557b9652650bb567f5..f6eccf445372471608fca231948b7c8540c20b12 100644 (file)
@@ -47,7 +47,7 @@
      <item>
       <widget class="QPushButton" name="browseButton">
        <property name="text">
-        <string>Browse</string>
+        <string>Browse...</string>
        </property>
        <property name="flat">
         <bool>false</bool>