summaryrefslogtreecommitdiffstats
path: root/tdecachegrind/tdecachegrind/main.cpp
blob: d1d3fc56a28eaa63c8ae2dbc8b9f4e1c0f18ed4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* This file is part of KCachegrind.
   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>

   KCachegrind is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation, version 2.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

/*
 * KCachegrind startup
 */

// for TDECACHEGRIND_VERSION
#include "../version.h"

#include <tqfile.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>

#include "toplevel.h"
#include "tracedata.h"
#include "loader.h"

static KCmdLineOptions options[] =
{
  { "r <exec>", I18N_NOOP("Run <exec> under cachegrind"), 0 },
  { "+[trace]", I18N_NOOP("Show information of this trace"), 0 },
  KCmdLineLastOption // End of options.
};

int main( int argc, char ** argv )
{
  KAboutData aboutData("tdecachegrind",
                       I18N_NOOP("KCachegrind"),
                       TDECACHEGRIND_VERSION,
                       I18N_NOOP("TDE Frontend for Cachegrind"),
                       KAboutData::License_GPL,
                       I18N_NOOP("(C) 2002, 2003, 2004"), 0,
		       "http://tdecachegrind.sf.net");
  aboutData.addAuthor("Josef Weidendorfer",
                      I18N_NOOP("Author/Maintainer"),
                      "Josef.Weidendorfer@gmx.de");

  KCmdLineArgs::init(argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions( options );

  KApplication a;
  TopLevel* t;
  Loader::initLoaders();

  if (a.isRestored()){
    int n = 1;
    while (KMainWindow::canBeRestored(n)){
      (new TopLevel())->restore(n);
      n++;
    }
  }
  else {
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if (args->count()>0) {
      for(int i = 0; i < args->count(); i++) {
        t = new TopLevel();
        t->show();
        t->loadDelayed(TQFile::decodeName(args->arg(i)));
      }
    }
    else {
      // load trace in current dir
      t = new TopLevel();
      t->show();
      t->loadDelayed(".");
    }
  }

  a.connect( &a, TQT_SIGNAL( lastWindowClosed() ), &a, TQT_SLOT( quit() ) );
  int res = a.exec();

  // to make leak checking in valgrind happy...
  Loader::deleteLoaders();
  TraceItem::cleanup();

  return res;
}