From ec251ede27e0dfce61feb8c640d8a7877c0df89d Mon Sep 17 00:00:00 2001 From: SVN User Date: Tue, 16 Mar 2010 22:31:45 +0000 Subject: [PATCH] * RCS.cpp, FWWindow.cpp: Fixed #1334 Program failed to open data file on Windows if it was stored on mounted network volume. "File/Open" operation terminated with no error but did not load the file. "File/Open Recent" ended with an error message that quoted file path as somehting like this: "Volume{3c50bdba-21b0-4ea5-b52f-aa5d9755f918}/test1.fwb" which was obviously incorrect and the file could not be loaded. --- build_num | 2 +- doc/ChangeLog | 10 ++++++++++ src/gui/FWWindow.cpp | 30 +++++++++++++++++++++++++----- src/gui/RCS.cpp | 5 +++-- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/build_num b/build_num index 004902fa5..621bfde35 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 2723 +#define BUILD_NUM 2724 diff --git a/doc/ChangeLog b/doc/ChangeLog index 4e5b4ea05..65e3b75dc 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,13 @@ +2010-03-16 + + * RCS.cpp, FWWindow.cpp: Fixed #1334 Program failed to open data + file on Windows if it was stored on mounted network volume. + "File/Open" operation terminated with no error but did not load + the file. "File/Open Recent" ended with an error message that + quoted file path as somehting like this: + "Volume{3c50bdba-21b0-4ea5-b52f-aa5d9755f918}/test1.fwb" + which was obviously incorrect and the file could not be loaded. + 2010-03-15 vadim * PolicyCompiler_PrintRule.cpp (PrintRule::_printOptionalGlobalRules): diff --git a/src/gui/FWWindow.cpp b/src/gui/FWWindow.cpp index 3e4135149..7300a2db4 100644 --- a/src/gui/FWWindow.cpp +++ b/src/gui/FWWindow.cpp @@ -624,16 +624,32 @@ void FWWindow::fileOpen() return ; } + // Using absoluteFilePath(), see #1334 QFileInfo fi(file_name); - QString file_path = fi.canonicalFilePath(); - QMdiSubWindow* sw = alreadyOpened(file_path); + QString file_path = fi.absoluteFilePath(); + + if (fwbdebug) qDebug() << "FWWindow::fileOpen():" + << "File name: " << file_name + << "Absolute file path: " << file_path; + + QMdiSubWindow* sw = alreadyOpened(file_name); if (sw != NULL) { + if (fwbdebug) qDebug() << "This file is already opened"; // activate window with this file m_mainWindow->m_space->setActiveSubWindow(sw); return; } + QFileInfo file_path_info(file_path); + if (!file_path_info.exists() || !file_path_info.isReadable()) + { + QMessageBox::warning( + this,"Firewall Builder", + tr("File '%1' does not exist or is not readable").arg(file_path)); + return; + } + if (loadFile(file_path, false)) { updateOpenRecentMenu(file_name); @@ -643,19 +659,23 @@ void FWWindow::fileOpen() QCoreApplication::postEvent(this, new updateSubWindowTitlesEvent()); } else m_mainWindow->m_space->setActiveSubWindow(last_active_window); - } QMdiSubWindow* FWWindow::alreadyOpened(const QString &file_name) { QFileInfo fi(file_name); - QString file_path = fi.canonicalFilePath(); + QString file_path = fi.absoluteFilePath(); + + if (fwbdebug) qDebug() << "FWWindow::alreadyOpened():" + << "File name: " << file_name + << "Absolute file path: " << file_path; + foreach(QMdiSubWindow* sw, m_mainWindow->m_space->subWindowList()) { ProjectPanel * pp = dynamic_cast(sw->widget()); if (pp!=NULL) { - if (fwbdebug) qDebug() << "Opened file " << pp->getFileName(); + if (fwbdebug) qDebug() << "Opened file" << pp->getFileName(); if (pp->getFileName() == file_path) return sw; } } diff --git a/src/gui/RCS.cpp b/src/gui/RCS.cpp index c871d1606..248b36acd 100644 --- a/src/gui/RCS.cpp +++ b/src/gui/RCS.cpp @@ -303,8 +303,9 @@ RCS::RCS(const QString &file) if (fwbdebug) qDebug() << "RCS::RCS(" << file << ")"; + // Using absoluteFilePath() rather than canonicalFilePath, see #1334 QFileInfo fi(file); - if (fi.exists()) filename = fi.canonicalFilePath(); + if (fi.exists()) filename = fi.absoluteFilePath(); else filename = file; if (fwbdebug) qDebug() << "filename=" << filename; @@ -469,7 +470,7 @@ void RCS::readFromStderr() void RCS::setFileName(const QString &fn) { QFileInfo fi(fn); - if (fi.exists()) filename = fi.canonicalFilePath(); + if (fi.exists()) filename = fi.absoluteFilePath(); else filename = fn; if (fwbdebug) qDebug() << "RCS::setFileName fn =" << fn << "filename =" << filename;