[rkward-cvs] SF.net SVN: rkward-code:[4721] trunk/rkward/rkward

tfry at users.sf.net tfry at users.sf.net
Thu Apr 25 10:33:41 UTC 2013


Revision: 4721
          http://sourceforge.net/p/rkward/code/4721
Author:   tfry
Date:     2013-04-25 10:33:39 +0000 (Thu, 25 Apr 2013)
Log Message:
-----------
Try to get better bug reports:
- If the backend is unavailable, try to fill in as many details from the frontend as possible.
- New dialog for "reportable" bugs. For now the only place where this is used in the "backend has died" message.

Modified Paths:
--------------
    trunk/rkward/rkward/dialogs/CMakeLists.txt
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rkrbackend.cpp
    trunk/rkward/rkward/rbackend/rksessionvars.cpp
    trunk/rkward/rkward/rbackend/rksessionvars.h
    trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp

Added Paths:
-----------
    trunk/rkward/rkward/dialogs/rkerrordialog.cpp
    trunk/rkward/rkward/dialogs/rkerrordialog.h

Modified: trunk/rkward/rkward/dialogs/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/dialogs/CMakeLists.txt	2013-04-25 09:22:20 UTC (rev 4720)
+++ trunk/rkward/rkward/dialogs/CMakeLists.txt	2013-04-25 10:33:39 UTC (rev 4721)
@@ -10,6 +10,7 @@
    rkimportdialog.cpp
    rkselectlistdialog.cpp
    rkrecoverdialog.cpp
+   rkerrordialog.cpp
    )
 
 QT4_AUTOMOC(${dialogs_STAT_SRCS})

Added: trunk/rkward/rkward/dialogs/rkerrordialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkerrordialog.cpp	                        (rev 0)
+++ trunk/rkward/rkward/dialogs/rkerrordialog.cpp	2013-04-25 10:33:39 UTC (rev 4721)
@@ -0,0 +1,113 @@
+/***************************************************************************
+                          rkerrordialog  -  description
+                             -------------------
+    begin                : Thu Apr 25 2013
+    copyright            : (C) 2013 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "rkerrordialog.h"
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kvbox.h>
+#include <QLabel>
+#include <QTextEdit>
+
+#include "../rbackend/rinterface.h"
+#include "../rbackend/rksessionvars.h"
+#include "../misc/rkprogresscontrol.h"
+#include "../rkglobals.h"
+#include "../rkward.h"
+
+#include "../debug.h"
+
+void RKErrorDialog::reportableErrorMessage (QWidget* parent_widget, const QString& user_message, const QString &details, const QString& caption, const QString& message_code) {
+	RK_TRACE (APP);
+
+	if (!parent_widget) parent_widget = RKWardMainWindow::getMain ();
+	// adjusted from KMessageBox::detailedError
+	KDialog *dialog = new KDialog (parent_widget, Qt::Dialog);
+	dialog->setCaption (caption);
+	if (details.isEmpty ()) dialog->setButtons (KDialog::Ok | KDialog::No);
+	else dialog->setButtons (KDialog::Ok | KDialog::No | KDialog::Details);
+	dialog->setButtonText (KDialog::No, i18n ("Report As Bug"));
+	dialog->setObjectName ("error");
+	dialog->setDefaultButton (KDialog::Ok);
+	dialog->setEscapeButton (KDialog::Ok);
+	KMessageBox::Options options = KMessageBox::Notify | KMessageBox::AllowLink;
+	dialog->setModal (true);
+
+	int ret = KMessageBox::createKMessageBox (dialog, QMessageBox::Critical, user_message, QStringList(), QString(), 0, options, details);
+
+	if (ret == KDialog::No) {
+		reportBug (parent_widget, (message_code.isEmpty () ? QString () : i18n ("Message code: %1\n", message_code)) + user_message);
+	}
+}
+
+void RKErrorDialog::reportBug (QWidget* parent_widget, const QString& message_info) {
+	RK_TRACE (APP);
+
+	if (!parent_widget) parent_widget = RKWardMainWindow::getMain ();
+
+	QString report_template = i18n ("---Problem description---\n");
+	if (message_info.isEmpty ()) {
+		report_template.append (i18n ("Please give a brief summary on the problem:\n###Please fill in###\n\n"));
+	} else {
+		report_template.append (i18n ("I encountered the error message quoted below. Additionally, I saw the following symptoms:\n###Please fill in (if applicable)###\n\n"));
+	}
+	report_template.append (i18n ("What - in detail - did you do directly before you encountered this problem?\n###Please fill in###\n\n"));
+	report_template.append (i18n ("When you try to repeat the above, does the problem occur again (no, sometimes, always)?\n###Please fill in###\n\n"));
+	report_template.append (i18n ("If applicable: When doing the same thing in an R session outside of RKWard, do you see the same problem?\n###Please fill in###\n\n"));
+	report_template.append (i18n ("Do you have any further information that might help us to track this problem down? In particular, if applicable, can you provide sample data and sample R code to reproduce this problem?\n###Please fill in###\n\n"));
+
+	if (!message_info.isEmpty ()) {
+		report_template.append ("\n---Error Message---\n");
+		report_template.append (message_info);
+		report_template.append ("\n");
+	}
+
+	report_template.append ("\n---Session Info---\n");
+	bool ok = false;
+	if (!RKGlobals::rInterface ()->backendIsDead ()) {
+		RCommand *command = new RCommand ("rk.sessionInfo()", RCommand::App);
+		RKProgressControl *control = new RKProgressControl (parent_widget, i18n ("Please stand by while gathering some information on your setup.\nIn case the backend has died or hung up, you may want to press 'Cancel' to skip this step."), i18n ("Gathering setup information"), RKProgressControl::CancellableNoProgress);
+		control->addRCommand (command, true);
+		RKGlobals::rInterface ()->issueCommand (command);
+		ok = control->doModal (false);
+		report_template.append (control->fullCommandOutput ());
+		delete control;
+	}
+	if (!ok) {
+		report_template.append (RKSessionVars::frontendSessionInfo ().join ("\n"));
+		report_template.append ("\n- backend not available or rk.sessionInfo() canceled -\n");
+	}
+
+	KDialog *dialog = new KDialog (parent_widget);
+	QObject::connect (dialog, SIGNAL (finished(int)), dialog, SLOT (deleteLater()));
+	dialog->setCaption (i18n ("Reporting bugs in RKWard"));
+	dialog->setButtons (KDialog::Ok);
+	KVBox *vbox = new KVBox (dialog);
+	dialog->setMainWidget (vbox);
+	QLabel *label = new QLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Please submit your bug reports or wishes at <a href=\"%1\">%1</a> or send email to <a href=\"mailto:%2\">%2</a>.</p>"
+							"<p><b>What information should I provide?</b></p><p>Please copy the information shown below, and fill in the details to the questions.</p>"
+							, QString ("http://sourceforge.net/tracker/?group_id=50231&atid=459007"), QString ("rkward-devel at lists.sourceforge.net")), vbox);
+	label->setWordWrap (true);
+	label->setOpenExternalLinks (true);
+	QTextEdit *details = new QTextEdit (vbox);
+	details->setReadOnly (true);
+	details->setText (report_template);
+
+	dialog->show ();
+
+}

Added: trunk/rkward/rkward/dialogs/rkerrordialog.h
===================================================================
--- trunk/rkward/rkward/dialogs/rkerrordialog.h	                        (rev 0)
+++ trunk/rkward/rkward/dialogs/rkerrordialog.h	2013-04-25 10:33:39 UTC (rev 4721)
@@ -0,0 +1,32 @@
+/***************************************************************************
+                          rkerrordialog  -  description
+                             -------------------
+    begin                : Thu Apr 25 2013
+    copyright            : (C) 2013 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+ 
+#ifndef RKERRORDIALOG_H
+#define RKERRORDIALOG_H
+
+#include <QString>
+
+class QWidget;
+
+namespace RKErrorDialog {
+/** Displays an error message with a button "Report bug" */
+	void reportableErrorMessage (QWidget *parent_widget, const QString &user_message, const QString &details, const QString &caption, const QString &message_code);
+/** Open "Report bug" dialog */
+	void reportBug (QWidget *parent_widget = 0, const QString &message_info=QString ());
+};
+
+#endif

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2013-04-25 09:22:20 UTC (rev 4720)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2013-04-25 10:33:39 UTC (rev 4721)
@@ -26,13 +26,13 @@
 #include "../settings/rksettingsmoduleoutput.h"
 #include "../settings/rksettingsmodulegraphics.h"
 #include "../settings/rksettingsmoduleplugins.h"
-#include "../settings/rksettingsmoduledebug.h"
 #include "../core/robjectlist.h"
 #include "../core/renvironmentobject.h"
 #include "../core/rkmodificationtracker.h"
 #include "../dialogs/rkloadlibsdialog.h"
 #include "../dialogs/rkselectlistdialog.h"
 #include "../dialogs/rkreadlinedialog.h"
+#include "../dialogs/rkerrordialog.h"
 #include "../agents/showedittextfileagent.h"
 #include "../agents/rkeditobjectagent.h"
 #include "../agents/rkprintagent.h"
@@ -59,7 +59,6 @@
 #include <kmessagebox.h>
 #include <kfiledialog.h>
 #include <klocale.h>
-#include <ktemporaryfile.h>
 #include <kstandarddirs.h>
 
 #include <qdir.h>
@@ -602,15 +601,11 @@
 		}
 	} else if (call == "getSessionInfo") {
 		// Non-translatable on purpose. This is meant for posting to the bug tracker, mostly.
-		QStringList lines;
-		lines.append ("RKWard version: " RKWARD_VERSION);
-		lines.append ("KDE version (runtime): " + QString (KDE::versionString ()));
-		lines.append ("KDE version (compile time): " KDE_VERSION_STRING);
-		lines.append ("Local KDE directory: " + KGlobal::dirs ()->localkdedir ());
-		lines.append ("RKWard storage directory: " + RKSettingsModuleGeneral::filesPath ());
-		lines.append (QString());
-		lines.append ("Debug message file(s) in use (these may contain relevant diagnostic output in case of trouble):");
-		lines.append (RKSettingsModuleDebug::debug_file->fileName ());
+		QStringList lines ("-- Frontend --");
+		lines.append (RKSessionVars::frontendSessionInfo ());
+		lines.append (QString ());
+		lines.append ("-- Backend --");
+		lines.append ("Debug message file (this may contain relevant diagnostic output in case of trouble):");
 		lines.append (calllist.value (1));
 		lines.append (QString ());
 		lines.append ("R version (compile time): " + calllist.value (2));
@@ -844,8 +839,8 @@
 		if (!backend_dead) {
 			backend_dead = true;
 			QString message = request->params["message"].toString ();
-			message += i18n ("\nThe R backend will be shut down immediately. This means, you can not use any more functions that rely on it. I.e. you can do hardly anything at all, not even save the workspace (but if you're lucky, R already did that). What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that.\nSince this should never happen, please write a mail to rkward-devel at lists.sourceforge.net, and tell us, what you were trying to do, when this happened. Sorry!");
-			KMessageBox::error (0, message, i18n ("R engine has died"));
+			message += i18n ("\nThe R backend will be shut down immediately. This means, you can not use any more functions that rely on it. I.e. you can do hardly anything at all, not even save the workspace (but if you're lucky, R already did that). What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that. Sorry!");
+			RKErrorDialog::reportableErrorMessage (0, message, QString (), i18n ("R engine has died"), "r_engine_has_died");
 		}
 	} else {
 		RK_ASSERT (false);

Modified: trunk/rkward/rkward/rbackend/rksessionvars.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rksessionvars.cpp	2013-04-25 09:22:20 UTC (rev 4720)
+++ trunk/rkward/rkward/rbackend/rksessionvars.cpp	2013-04-25 10:33:39 UTC (rev 4721)
@@ -18,8 +18,17 @@
 #include "rksessionvars.h"
 
 #include "rinterface.h"
+#include "../settings/rksettingsmoduledebug.h"
+#include "../settings/rksettingsmodulegeneral.h"
 #include "../version.h"
 
+#include <kdeversion.h>
+#include <ktemporaryfile.h>
+#include <kstandarddirs.h>
+
+#include <QLibraryInfo>
+#include <QSysInfo>
+
 #include "../debug.h"
 
 RKSessionVars* RKSessionVars::_instance = 0;
@@ -110,4 +119,24 @@
 	return 0;
 }
 
+QStringList RKSessionVars::frontendSessionInfo () {
+	QStringList lines;
+	lines.append ("RKWard version: " RKWARD_VERSION);
+	lines.append ("KDE version (runtime): " + QString (KDE::versionString ()));
+	lines.append ("KDE version (compile time): " KDE_VERSION_STRING);
+	lines.append ("Qt build key: " + QLibraryInfo::buildKey ());
+#if defined Q_WS_WIN
+	lines.append ("Windows runtime version (refer to QSysInfo documentation to translate code into human readable form): 0x" + QString::number (QSysInfo::windowsVersion (), 16));
+#elif defined Q_WS_MAC
+	lines.append ("MacOS runtime version (refer to QSysInfo documentation to translate code into human readable form): 0x" + QString::number (QSysInfo::MacintoshVersion, 16));
+#endif
+	lines.append ("Local KDE directory: " + KGlobal::dirs ()->localkdedir ());
+	lines.append ("RKWard storage directory: " + RKSettingsModuleGeneral::filesPath ());
+	lines.append ("Backend version (as known to the frontend): " + r_version_string);
+	lines.append (QString());
+	lines.append ("Debug message file (this may contain relevant diagnostic output in case of trouble):");
+	lines.append (RKSettingsModuleDebug::debug_file->fileName ());
+	return lines;
+}
+
 #include "rksessionvars.moc"

Modified: trunk/rkward/rkward/rbackend/rksessionvars.h
===================================================================
--- trunk/rkward/rkward/rbackend/rksessionvars.h	2013-04-25 09:22:20 UTC (rev 4720)
+++ trunk/rkward/rkward/rbackend/rksessionvars.h	2013-04-25 10:33:39 UTC (rev 4721)
@@ -39,6 +39,7 @@
 Anything else (everything after the fourth dot, or after the first character that is neither dot, nor digit)
 is returned as suffix (via the suffix pointer; if that is 0, an error is reported, instead). */
 	static quint32 parseVersionString (const QString &version, QString *suffix);
+	static QStringList frontendSessionInfo ();
 signals:
 	void installedPackagesChanged ();
 protected:

Modified: trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp	2013-04-25 09:22:20 UTC (rev 4720)
+++ trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp	2013-04-25 10:33:39 UTC (rev 4721)
@@ -41,6 +41,7 @@
 #include "../misc/rkprogresscontrol.h"
 #include "../misc/rkcommonfunctions.h"
 #include "../plugin/rkcomponentmap.h"
+#include "../dialogs/rkerrordialog.h"
 #include "../rbackend/rinterface.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
@@ -141,42 +142,7 @@
 }
 
 void RKTopLevelWindowGUI::reportRKWardBug () {
-	RK_TRACE (APP);
-
-	QString report_template = i18n ("---Problem description---\n");
-	report_template.append (i18n ("Please give a brief summary on the problem:\n###Please fill in###\n\n"));
-	report_template.append (i18n ("What - in detail - did you do directly before you encountered this problem?\n###Please fill in###\n\n"));
-	report_template.append (i18n ("When you try to repeat the above, does the problem occur again (no, sometimes, always)?\n###Please fill in###\n\n"));
-	report_template.append (i18n ("If applicable: When doing the same thing in an R session outside of RKWard, do you see the same problem?\n###Please fill in###\n\n"));
-	report_template.append (i18n ("Do you have any further information that might help us to track this problem down? In particular, if applicable, can you provide sample data and sample R code to reproduce this problem?\n###Please fill in###\n\n"));
-
-	RCommand *command = new RCommand ("rk.sessionInfo()", RCommand::App);
-	RKProgressControl *control = new RKProgressControl (this, i18n ("Please stand by while gathering some information on your setup.\nIn case the backend has died or hung up, you may want to press 'Cancel' to skip this step."), i18n ("Gathering setup information"), RKProgressControl::CancellableNoProgress);
-	control->addRCommand (command, true);
-	RKGlobals::rInterface ()->issueCommand (command);
-	bool ok = control->doModal (false);
-
-	report_template.append ("---Session Info---\n");
-	report_template.append (control->fullCommandOutput ());
-	if (!ok) report_template.append ("- not available -");
-	delete control;
-
-	KDialog *dialog = new KDialog (for_window);
-	connect (dialog, SIGNAL (finished(int)), dialog, SLOT (deleteLater()));
-	dialog->setCaption (i18n ("Reporting bugs in RKWard"));
-	dialog->setButtons (KDialog::Ok);
-	KVBox *vbox = new KVBox (dialog);
-	dialog->setMainWidget (vbox);
-	QLabel *label = new QLabel (i18n ("<p><b>Where should I report bugs or wishes?</b></p><p>Please submit your bug reports or wishes at <a href=\"%1\">%1</a> or send email to <a href=\"mailto:%2\">%2</a>.</p>"
-							"<p><b>What information should I provide?</b></p><p>Please copy the information shown below, and fill in the details to the questions.</p>"
-							, QString ("http://sourceforge.net/tracker/?group_id=50231&atid=459007"), QString ("rkward-devel at lists.sourceforge.net")), vbox);
-	label->setWordWrap (true);
-	label->setOpenExternalLinks (true);
-	QTextEdit *details = new QTextEdit (vbox);
-	details->setReadOnly (true);
-	details->setText (report_template);
-
-	dialog->show ();
+	RKErrorDialog::reportBug (for_window);
 }
 
 void RKTopLevelWindowGUI::showAboutApplication () {





More information about the rkward-tracker mailing list