Summary: | Log on project event does not work | ||
---|---|---|---|
Product: | [Unmaintained] quanta | Reporter: | Yuri <yoghoyogho> |
Component: | general | Assignee: | András Manţia <amantia> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian stable | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Yuri
2006-08-03 16:11:07 UTC
I really wanted to know if this works, so I finally decided to install kdevelop etc, and download the sources. I see in utility/qpevents.cpp on line 276: if (!logFile.startsWith("/")) When you enter a filename starting with a / as I did, this line of code prevents the logging from happening. The only reason for this check to be there I can think of is security. You probably don't want the logging to happen over /etc/passwd etc... It would be nice though that the user would get some feedback that the logging isn't happening because of this. I'd probably add after line 314 (in the else branch of the above mentioned 'if'): KMessageBox::sorry(0L, i18n("Logging is only allowed in the project directory.")); Conclusion: 1. The warning for execution still comes at the wrong time 2. Logging is not allowed outside of the project directory. Unfortunately there is no warning that nothing is logged if a filename was specified outside of the project directory. SVN commit 580055 by amantia: - allow logging to files outside of project directory - don't send closing events for untitled, unmodified documents BUG: 131782 M +2 -0 ChangeLog M +7 -2 src/quantaview.cpp M +46 -47 utility/qpevents.cpp --- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #580054:580055 @@ -12,6 +12,8 @@ - show the correct column number if tabs are used in the document [#133313] - only one upload dialog can be shown at any time [#132535] - do not show Find in Files menu if KFileReplace is not installed [#132530] + - allow logging to files outside of project directory [#131782] + - don't send closing events for untitled, unmodified documents [#131782] Version 3.5.4 (Release date: 02-08-2006; Started 24-06-2005): - bugfixes: --- branches/KDE/3.5/kdewebdev/quanta/src/quantaview.cpp #580054:580055 @@ -132,6 +132,9 @@ m_plugin->unload(false); } else { + bool unmodifiedUntitled = false; + if (m_document && m_document->isUntitled() && !m_document->isModified()) + unmodifiedUntitled = true; if (m_customWidget) m_customWidget->reparent(0L, 0, QPoint(), false); if (!saveModified()) @@ -149,7 +152,8 @@ { KURL url = m_document->url(); Project::ref()->saveBookmarks(url, dynamic_cast<KTextEditor::MarkInterface*>(m_document->doc())); - emit eventHappened("before_close", url.url(), QString::null); + if (!unmodifiedUntitled) + emit eventHappened("before_close", url.url(), QString::null); m_currentViewsLayout = -1; // m_document->closeTempFile(); if (!m_document->isUntitled() && url.isLocalFile()) @@ -161,7 +165,8 @@ quantaApp->menuBar()->activateItemAt(-1); quantaApp->guiFactory()->removeClient(m_document->view()); - emit eventHappened("after_close", url.url(), QString::null); + if (!unmodifiedUntitled) + emit eventHappened("after_close", url.url(), QString::null); } /* kdDebug(24000) << "Calling reparse from close " << endl; parser->setSAParserEnabled(true); --- branches/KDE/3.5/kdewebdev/quanta/utility/qpevents.cpp #580054:580055 @@ -104,7 +104,7 @@ ev.arguments << i18n("An upload was initiated"); ev.arguments << url.path(); handleEvent(ev); - } + } } if (inProject && url2.isValid()) { @@ -266,53 +266,52 @@ } if (ev.action == "log") { - QString logFile = ev.arguments[0]; - KURL url = KURL::fromPathOrURL(logFile); - if (url.isValid() && !url.isLocalFile()) - { - KMessageBox::sorry(0L, i18n("Logging to remote files is not supported.")); + QString logFile = ev.arguments[0]; + KURL url = KURL::fromPathOrURL(logFile); + if (url.isValid() && !url.isLocalFile()) + { + KMessageBox::sorry(0L, i18n("Logging to remote files is not supported.")); + return false; + } + if (!logFile.startsWith("/")) + { + url = Project::ref()->projectBaseURL(); + url.addPath(logFile); + if (!url.isLocalFile()) + { + KMessageBox::sorry(0L, i18n("Logging to files inside a remote project is not supported.")); return false; - } - if (!logFile.startsWith("/")) - { - url = Project::ref()->projectBaseURL(); - url.addPath(logFile); - if (!url.isLocalFile()) - { - KMessageBox::sorry(0L, i18n("Logging to files inside a remote project is not supported.")); - return false; - } - QFile file(url.path()); - bool result; - if (ev.arguments[2] == "create_new") - result = file.open(IO_WriteOnly); - else - result = file.open(IO_WriteOnly | IO_Append); - if (result) - { - QTextStream stream(&file); - //Note: the log text should not be translated. - QString s = QDateTime::currentDateTime().toString(Qt::ISODate) + ": "; - s.append( "Event : " + m_eventName + " : "); - s.append( "Action: " + ev.action + " : "); - if (ev.arguments[1] == "full") - { - s.append( "Arguments: "); - for (uint i = 1; i < ev.arguments.count(); i++) - s.append(ev.arguments[i] + " | "); - } - s[s.length() - 1] = '\n'; - stream << s; - file.close(); - } - if (!result) - { - KMessageBox::sorry(0L, i18n("<qt>Logging failed. Check that you have write access to <i>%1</i>.").arg(url.prettyURL(KURL::StripFileProtocol))); - return false; - } - } else - { - } + } + } + QFile file(url.path()); + bool result; + if (ev.arguments[2] == "create_new") + result = file.open(IO_WriteOnly); + else + result = file.open(IO_WriteOnly | IO_Append); + if (result) + { + QTextStream stream(&file); + stream.setEncoding(QTextStream::UnicodeUTF8); + //Note: the log text should not be translated. + QString s = QDateTime::currentDateTime().toString(Qt::ISODate) + ": "; + s.append( "Event : " + m_eventName + " : "); + s.append( "Action: " + ev.action + " : "); + if (ev.arguments[1] == "full") + { + s.append( "Arguments: "); + for (uint i = 1; i < ev.arguments.count(); i++) + s.append(ev.arguments[i] + " | "); + } + s[s.length() - 1] = '\n'; + stream << s; + file.close(); + } + if (!result) + { + KMessageBox::sorry(0L, i18n("<qt>Logging failed. Check that you have write access to <i>%1</i>.").arg(url.path())); + return false; + } } else KMessageBox::sorry(0L, i18n("<qt>Unsupported internal event action : <b>%1</b>.</qt>").arg(ev.action)); } else This is great Andras, thanks a lot! |