|
From: <sv...@va...> - 2008-06-10 20:13:56
|
Author: cerion
Date: 2008-06-09 22:18:36 +0100 (Mon, 09 Jun 2008)
New Revision: 428
Log:
Fix log dir setup (as requested by many!)
Temporary logs are now always written to /tmp/valkyrie_logs (configured value)
Added a user configurable "Log Dir", which is used as the default dir
when saving logs.
Modified:
trunk/configure.in
trunk/valkyrie/core/memcheck_object.cpp
trunk/valkyrie/core/valkyrie_object.cpp
trunk/valkyrie/core/valkyrie_object.h
trunk/valkyrie/options/valkyrie_options_page.cpp
trunk/valkyrie/options/valkyrie_options_page.h
trunk/valkyrie/options/vk_option.cpp
trunk/valkyrie/vk_config.cpp
trunk/valkyrie/vk_config.h
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/configure.in 2008-06-09 21:18:36 UTC (rev 428)
@@ -2,7 +2,7 @@
########################################################################
# ? AC_PREREQ(2.59)
-AC_INIT(Valkyrie, 1.2.0, in...@op...)
+AC_INIT(Valkyrie, 1.2.1, in...@op...)
AC_CONFIG_SRCDIR([valkyrie/main.cpp])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR(m4)
@@ -193,10 +193,10 @@
AC_DEFINE_UNQUOTED(VK_DOC_PATH, "/doc/", [valkyrie install doc path])
# valkyrie config paths
-AC_DEFINE_UNQUOTED(VK_CFG_DIR, ".$PACKAGE", [valkyrie config dir])
-AC_DEFINE_UNQUOTED(VK_DBASE_DIR, "/dbase/", [valkyrie config dbase dir])
-AC_DEFINE_UNQUOTED(VK_LOGS_DIR, "/logs/", [valkyrie config logs dir])
-AC_DEFINE_UNQUOTED(VK_SUPPS_DIR, "/suppressions/", [valkyrie config supps dir])
+AC_DEFINE_UNQUOTED(VK_CFG_DIR, ".$PACKAGE", [valkyrie config dir])
+AC_DEFINE_UNQUOTED(VK_DBASE_DIR, "dbase/", [valkyrie config dbase dir])
+AC_DEFINE_UNQUOTED(VK_SUPPS_DIR, "suppressions/", [valkyrie config supps dir])
+AC_DEFINE_UNQUOTED(VK_LOGS_DIR, "/tmp/valkyrie_logs/", [valkyrie config logs dir])
# programs
AC_DEFINE_UNQUOTED(BIN_VALGRIND, "$VALGRIND", [valgrind executable])
Modified: trunk/valkyrie/core/memcheck_object.cpp
===================================================================
--- trunk/valkyrie/core/memcheck_object.cpp 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/core/memcheck_object.cpp 2008-06-09 21:18:36 UTC (rev 428)
@@ -8,6 +8,7 @@
* See the file LICENSE.GPL for the full license details.
*/
+#include "config.h"
#include "memcheck_object.h"
#include "valkyrie_object.h"
#include "vk_config.h"
@@ -322,12 +323,15 @@
}
-/* if --vg-opt=<arg> was specified on the cmd-line, called by
+/* If --vg-opt=<arg> was specified on the cmd-line, called by
valkyrie->runTool(); if set via the run-button in the gui,
- then MainWindow::run() calls valkyrie->runTool(). */
+ then MainWindow::run() calls valkyrie->runTool().
+
+ Auto-generated logs always saved in hard-coded (configured) log dir
+*/
bool Memcheck::runValgrind( QStringList vgflags )
{
- m_saveFname = vk_mkstemp( vkConfig->logsDir() + "mc_log", "xml" );
+ m_saveFname = vk_mkstemp( QString( VK_LOGS_DIR ) + "mc_log", "xml" );
vk_assert( !m_saveFname.isEmpty() );
/* check valgrind version:
@@ -430,7 +434,8 @@
QString fname_logList = vkConfig->rdEntry( "merge", "valkyrie" );
statusMsg( "Merging logs in file-list", fname_logList );
- m_saveFname = vk_mkstemp( vkConfig->logsDir() + "mc_merged", "xml" );
+ QString logDir = vkConfig->rdEntry( "default-logdir", "valkyrie" );
+ m_saveFname = vk_mkstemp( logDir + "mc_merged", "xml" );
vk_assert( !m_saveFname.isEmpty() );
QStringList flags;
@@ -653,10 +658,12 @@
}
-/* brings up a fileSaveDialog until successfully saved,
+/* Brings up a fileSaveDialog until successfully saved,
or user pressed Cancel.
- if fname.isEmpty, ask user for a name first.
+ If fname.isEmpty, ask user for a name first.
returns false on user pressing Cancel, else true.
+
+ Save-dialog started in user-configured default log dir
*/
bool Memcheck::fileSaveDialog( QString fname/*=QString()*/ )
{
@@ -669,8 +676,8 @@
/* Ask fname if don't have one already */
if ( fname.isEmpty() ) {
- /* start dlg in dir of last saved logfile */
- QString start_path = QFileInfo( m_saveFname ).dirPath();
+ /* Start save-dialog in User-configured default log dir*/
+ QString start_path = vkConfig->rdEntry( "default-logdir", "valkyrie" );
fname = dlg.getSaveFileName( start_path, flt, view(), "fsdlg", cptn );
if ( fname.isEmpty() )
return false;
Modified: trunk/valkyrie/core/valkyrie_object.cpp
===================================================================
--- trunk/valkyrie/core/valkyrie_object.cpp 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/core/valkyrie_object.cpp 2008-06-09 21:18:36 UTC (rev 428)
@@ -96,7 +96,11 @@
addOpt( BROWSER, VkOPTION::NOT_POPT, VkOPTION::WDG_LEDIT,
"valkyrie", '\0', "browser",
"", "", "",
- "Browser", "", urlValkyrie::browser );
+ "Browser:", "", urlValkyrie::browser );
+ addOpt( DFLT_LOGDIR, VkOPTION::NOT_POPT, VkOPTION::WDG_LEDIT,
+ "valkyrie", '\0', "default-logdir",
+ "", "", VK_LOGS_DIR,
+ "Log Dir:", "", "" );
/* path to valgrind executable (maybe found by configure) */
addOpt( VG_EXEC, VkOPTION::NOT_POPT, VkOPTION::WDG_LEDIT,
@@ -155,6 +159,11 @@
return errval;
break;
+ case DFLT_LOGDIR: {
+ /* see if we have an dir with rx permissions */
+ (void) dirCheck( &errval, argval, true, true );
+ } break;
+
case SRC_EDITOR: {
QString ed_file = QStringList::split(" ", argval).first();
QString ed = binaryCheck( &errval, ed_file );
Modified: trunk/valkyrie/core/valkyrie_object.h
===================================================================
--- trunk/valkyrie/core/valkyrie_object.h 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/core/valkyrie_object.h 2008-06-09 21:18:36 UTC (rev 428)
@@ -49,6 +49,7 @@
TOOLTIP, PALETTE, ICONTXT,
FNT_GEN_SYS, FNT_GEN_USR, FNT_TOOL_USR,
SRC_EDITOR, SRC_LINES, BROWSER,
+ DFLT_LOGDIR,
VG_EXEC, /* path to valgrind executable */
/* FIRST_CMD_OPT */
BINARY, BIN_FLAGS, VIEW_LOG, MERGE_EXEC, MERGE_LOGS,
Modified: trunk/valkyrie/options/valkyrie_options_page.cpp
===================================================================
--- trunk/valkyrie/options/valkyrie_options_page.cpp 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/options/valkyrie_options_page.cpp 2008-06-09 21:18:36 UTC (rev 428)
@@ -24,7 +24,7 @@
: OptionsPage( parent, obj, "valkyrie_options_page" )
{
/* init the QIntDict list, resizing if necessary */
- unsigned int numItems = 12;
+ unsigned int numItems = 13;
m_itemList.resize( numItems );
QVBoxLayout* vbox = new QVBoxLayout( this, m_margin, -1, "vbox" );
@@ -49,6 +49,12 @@
brwsrLedit->addButton( group1, this, SLOT(getBrowser()) );
connect(brwsrLedit, SIGNAL(returnPressed()), this, SIGNAL(apply()));
+ m_itemList.insert( Valkyrie::DFLT_LOGDIR, /* ledit + button */
+ optionWidget(Valkyrie::DFLT_LOGDIR, group1, false ) );
+ LeWidget* dirLogSave = ((LeWidget*)m_itemList[Valkyrie::DFLT_LOGDIR]);
+ dirLogSave->addButton( group1, this, SLOT(getDfltLogDir()) );
+ connect(dirLogSave, SIGNAL(returnPressed()), this, SIGNAL(apply()));
+
/* fonts --------------------------------------------------------- */
m_itemList.insert( Valkyrie::FNT_GEN_SYS, /* checkbox */
optionWidget( Valkyrie::FNT_GEN_SYS, group1, false ));
@@ -119,6 +125,10 @@
grid->addMultiCellWidget( brwsrLedit->widget(), i,i, 1,3 );
i++;
+ grid->addWidget( dirLogSave->button(), i, 0 );
+ grid->addMultiCellWidget( dirLogSave->widget(), i,i, 1,3 );
+ i++;
+
grid->addMultiCellWidget( sep(group1,"sep0"), i,i, 0,3 );
#if (QT_VERSION-0 >= 0x030200)
grid->setRowSpacing( i++, 8 );
@@ -360,3 +370,19 @@
checkOption( Valkyrie::VG_EXEC );
}
}
+
+
+/* RM: allows user to specify which valgrind version to use. the guts
+ of this fn are essentially the same as the one in config.tests/valgrind.test */
+void ValkyrieOptionsPage::getDfltLogDir()
+{
+ QString currdir = m_itemList[Valkyrie::DFLT_LOGDIR]->currValue();
+ QString dir_logsave =
+ QFileDialog::getExistingDirectory( currdir, this,
+ "get default log-save dir",
+ "Choose a directory", TRUE );
+ if ( !dir_logsave.isEmpty() ) { /* user might have clicked Cancel */
+ ((LeWidget*)m_itemList[Valkyrie::DFLT_LOGDIR])->setCurrValue( dir_logsave );
+ checkOption( Valkyrie::DFLT_LOGDIR );
+ }
+}
Modified: trunk/valkyrie/options/valkyrie_options_page.h
===================================================================
--- trunk/valkyrie/options/valkyrie_options_page.h 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/options/valkyrie_options_page.h 2008-06-09 21:18:36 UTC (rev 428)
@@ -27,6 +27,7 @@
void getEditor();
void getBinary();
void getBrowser();
+ void getDfltLogDir();
void getVgExec();
};
Modified: trunk/valkyrie/options/vk_option.cpp
===================================================================
--- trunk/valkyrie/options/vk_option.cpp 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/options/vk_option.cpp 2008-06-09 21:18:36 UTC (rev 428)
@@ -129,6 +129,7 @@
if ( rd_perms ) {
if ( !fi.isReadable() ) {
*err_val = PERROR_BADFILERD;
+ goto bye;
}
}
@@ -136,6 +137,7 @@
if ( wr_perms ) {
if ( !fi.isWritable() ) {
*err_val = PERROR_BADFILEWR;
+ goto bye;
}
}
@@ -182,6 +184,7 @@
if ( rd_perms ) {
if ( !fi.isReadable() ) {
*err_val = PERROR_BADFILERD;
+ goto bye;
}
}
@@ -189,6 +192,7 @@
if ( wr_perms ) {
if ( !fi.isWritable() ) {
*err_val = PERROR_BADFILEWR;
+ goto bye;
}
}
Modified: trunk/valkyrie/vk_config.cpp
===================================================================
--- trunk/valkyrie/vk_config.cpp 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/vk_config.cpp 2008-06-09 21:18:36 UTC (rev 428)
@@ -58,7 +58,7 @@
rcMap.insert( aIt.key(), dirtyEntry );
}
- /* write out updated config */
+ /* write out updated config */
if ( !writeConfig( rcMap ) ) {
VK_DEBUG( "failed to write updated config file" );
return false;
@@ -88,12 +88,10 @@
m_vg_copyright = VG_COPYRIGHT;
/* set full rc paths (see config.h) */
- m_rcPath.sprintf( "%s/.%s", QDir::homeDirPath().latin1(), vkname() );
- m_rcFileName.sprintf( "%s/%src", m_rcPath.latin1(), vkname() );
- m_dbasePath = m_rcPath + VK_DBASE_DIR;
- m_logsPath = m_rcPath + VK_LOGS_DIR;
- m_suppPath = m_rcPath + VK_SUPPS_DIR;
- m_rcPath += "/";
+ m_rcPath = QDir::homeDirPath() + "/." + vkname() + "/";
+ m_rcFileName = m_rcPath + vkname() + "rc";
+ m_dbasePath = m_rcPath + VK_DBASE_DIR;
+ m_suppPath = m_rcPath + VK_SUPPS_DIR;
m_defaultAppFont = QApplication::font();
}
@@ -130,7 +128,6 @@
QString VkConfig::vkdocDir() { return m_vkdocPath; }
QString VkConfig::rcDir() { return m_rcPath; }
QString VkConfig::dbaseDir() { return m_dbasePath; }
-QString VkConfig::logsDir() { return m_logsPath; }
QString VkConfig::suppDir() { return m_suppPath; }
/* valkyrie's default palette */
@@ -720,15 +717,15 @@
relevant data to ~/.PACKAGE/PACKAGErc */
bool VkConfig::writeConfigDefaults( Valkyrie* vk )
{
- QString default_config = mkConfigDefaults( vk );
- QTextStream strm( &default_config, IO_ReadOnly );
- EntryMap rcMap = parseConfigToMap( strm );
-
- /* Set valkyrie version: used for rc upgrading */
- rcMap[ EntryKey( "valkyrie", "version" ) ].mValue
- = PACKAGE_VERSION;
+ QString default_config = mkConfigDefaults( vk );
+ QTextStream strm( &default_config, IO_ReadOnly );
+ EntryMap rcMap = parseConfigToMap( strm );
+
+ /* Set valkyrie version: used for rc upgrading */
+ rcMap[ EntryKey( "valkyrie", "version" ) ].mValue
+ = PACKAGE_VERSION;
- /* Set our 'configured' valgrind paths, if we have them */
+ /* Set our 'configured' valgrind paths, if we have them */
{
rcMap[ EntryKey( "valkyrie", "merge-exec" ) ].mValue
= BIN_LOGMERGE;
@@ -743,11 +740,11 @@
= suppDir();
}
- /* write out new config */
- if ( !writeConfig( rcMap, true ) ) {
+ /* write out new config */
+ if ( !writeConfig( rcMap, true ) ) {
VK_DEBUG( "failed to write default config file" );
- return false;
- }
+ return false;
+ }
return true;
}
@@ -809,7 +806,7 @@
{
QStringList entries;
entries << m_rcPath << m_rcFileName
- << m_dbasePath << m_logsPath << m_suppPath;
+ << m_dbasePath << m_suppPath;
/* Note: don't just run through and test/fix: want to tell the user
if there was a problem with a previous config dir tree.
@@ -830,7 +827,7 @@
if (!ok) { /* rc tree !exists or !well */
/* this an existing tree?
if so, tell the user there was a problem */
- if (QFile::exists(m_rcPath)) {
+ if ( QFile::exists(m_rcPath) ) {
vkInfo( 0, "Checking Config Setup",
"<p>Detected missing configuration files/dirs.<br/>"
"Attempting to recreate from defaults...</p>" );
@@ -846,5 +843,12 @@
}
}
+ /* Further, check for temporary log dir (VK_LOGS_DIR), make if !exists */
+ if ( !QFile::exists( VK_LOGS_DIR ) ) {
+ if ( !checkRCEntry( VK_LOGS_DIR, vk) ) {
+ return false;
+ }
+ }
+
return true;
}
Modified: trunk/valkyrie/vk_config.h
===================================================================
--- trunk/valkyrie/vk_config.h 2008-06-09 21:09:38 UTC (rev 427)
+++ trunk/valkyrie/vk_config.h 2008-06-09 21:18:36 UTC (rev 428)
@@ -88,7 +88,6 @@
/* these fns return values held in private vars ---------------------- */
QString vkdocDir();
QString rcDir();
- QString logsDir();
QString dbaseDir();
QString suppDir();
QChar sepChar() { return m_sep; }
@@ -152,7 +151,6 @@
QString m_vkdocPath; /* path to valkyrie docs dir */
QString m_rcPath; /* path to ~/valkyrie=X.X.X dir */
QString m_rcFileName; /* where valkyrierc lives */
- QString m_logsPath; /* path to log dir */
QString m_dbasePath; /* path to dbase dir */
/* path to user's suppression files dir.
default is ~/.valkyrie/suppressions */
|