Commit e501b62d authored by Justin Hipple's avatar Justin Hipple
Browse files

Turns out that homePath isn't such a good place to use on Windows. The...

Turns out that homePath isn't such a good place to use on Windows. The installed directory is probably much more logical for Windows users as a default. Separator normalization now occurs in all necessary places. Fixed a bug that was causing messages not to be written to the log file if the Message Log hadn't been opened before starting Tor.

svn:r251
parent 214c9ced
Loading
Loading
Loading
Loading
+4 −3
Changes for src/config/vidaliasettings.cpp: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@
#define DEFAULT_ENABLE_LOG_FILE false

#if defined(Q_OS_WIN32)
#define DEFAULT_LOG_FILE       (QDir::homePath() + "\\Tor\\tor.log")
#define DEFAULT_LOG_FILE       "C:\\Program Files\\Tor\\tor.log"
#else
#define DEFAULT_LOG_FILE       (QDir::homePath() + "/.tor/tor.log")
#endif
@@ -282,14 +282,15 @@ VidaliaSettings::enableLogFile(bool enable)
QString
VidaliaSettings::getLogFile()
{
  return value(SETTING_LOG_FILE, DEFAULT_LOG_FILE).toString();
  return QDir::convertSeparators(
                  value(SETTING_LOG_FILE, DEFAULT_LOG_FILE).toString());
}

/** Sets the destination file on disk to which log messages can be saved. */
void
VidaliaSettings::setLogFile(QString file)
{
  setValue(SETTING_LOG_FILE, file);
  setValue(SETTING_LOG_FILE, QDir::convertSeparators(file));
}

/** Returns the bandwidth line filter. */
+7 −6
Changes for src/gui/messagelog/messagelog.cpp: 7 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -167,8 +167,7 @@ MessageLog::loadSettings()
  ui.lblPercentOpacity->setNum(ui.sldrOpacity->value());

  /* Set whether or not logging to file is enabled */
  _enableLogging = _settings->isLogFileEnabled();
  ui.chkEnableLogFile->setChecked(_enableLogging);
  ui.chkEnableLogFile->setChecked(_settings->isLogFileEnabled());
  ui.lineFile->setText(_settings->getLogFile());

  /* Set the checkboxes accordingly */
@@ -203,7 +202,6 @@ MessageLog::saveChanges()
  /* Try to open the log file. If it can't be opened, then give the user an
   * error message and stop saving the changes. */
  if (ui.chkEnableLogFile->isChecked()) {
    //QFileInfo file(ui.lineFile->text());
    if (!openLogFile(ui.lineFile->text())) {
      QMessageBox::warning(this, tr("Error Opening Log File"),
        tr("Vidalia was unable to open the specified log file for writing."),
@@ -211,6 +209,7 @@ MessageLog::saveChanges()
      return;
    }
    _settings->setLogFile(ui.lineFile->text());
    ui.lineFile->setText(QDir::convertSeparators(ui.lineFile->text()));
  }
  _settings->enableLogFile(ui.chkEnableLogFile->isChecked());
  
@@ -364,8 +363,10 @@ MessageLog::sort(QList<QTreeWidgetItem *> items)
void
MessageLog::browse()
{
  QString filename = QFileDialog::getSaveFileName(this,
                         tr("Select Log File"), "tor.log");
  /* Strangely, QFileDialog returns a non seperator converted path. */
  QString filename = QDir::convertSeparators(
                          QFileDialog::getSaveFileName(this,
                              tr("Select Log File"), "tor.log"));
  if (!filename.isEmpty()) {
    ui.lineFile->setText(filename);
  }
@@ -621,7 +622,7 @@ MessageLog::log(LogEvent::Severity type, QString message)
  }

  /* If we're saving log messages to a file, go ahead and do that now */
  if (_enableLogging) {
  if (_settings->isLogFileEnabled()) {
    _logStream << format(newMessage);
    _logStream.flush(); /* Write to disk right away */
  }
+1 −3
Changes for src/gui/messagelog/messagelog.h: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -126,11 +126,9 @@ private:
  int _maxCount;
  /** Holds the number of messages currently displayed **/
  int _messagesShown;
  /** Set to true if we will log all messages to a file. */
  bool _enableLogging;
  /** The log file used to store log messages. */
  QFile *_logFile;
  /** Text stream used to write to the log file if _enableLogging is true. */
  /** Text stream used to write to the log file if enabled*/
  QTextStream _logStream;

  /** Qt Designer generatated QObject **/