[rkward-cvs] SF.net SVN: rkward: [947] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Nov 27 13:59:58 UTC 2006
Revision: 947
http://svn.sourceforge.net/rkward/?rev=947&view=rev
Author: tfry
Date: 2006-11-27 05:59:58 -0800 (Mon, 27 Nov 2006)
Log Message:
-----------
Simple error handling for X11 window commands
Modified Paths:
--------------
trunk/rkward/rkward/misc/rkerrordialog.cpp
trunk/rkward/rkward/misc/rkerrordialog.h
trunk/rkward/rkward/rbackend/rcommandreceiver.cpp
trunk/rkward/rkward/rbackend/rcommandreceiver.h
trunk/rkward/rkward/windows/rkwindowcatcher.cpp
trunk/rkward/rkward/windows/rkwindowcatcher.h
Modified: trunk/rkward/rkward/misc/rkerrordialog.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkerrordialog.cpp 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/misc/rkerrordialog.cpp 2006-11-27 13:59:58 UTC (rev 947)
@@ -2,7 +2,7 @@
rkerrordialog - description
-------------------
begin : Fri Jul 30 2004
- copyright : (C) 2004 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Modified: trunk/rkward/rkward/misc/rkerrordialog.h
===================================================================
--- trunk/rkward/rkward/misc/rkerrordialog.h 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/misc/rkerrordialog.h 2006-11-27 13:59:58 UTC (rev 947)
@@ -2,7 +2,7 @@
rkerrordialog - description
-------------------
begin : Fri Jul 30 2004
- copyright : (C) 2004 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -59,7 +59,7 @@
};
#include "../rbackend/rcommandreceiver.h"
-/** A subclass of RKErrorDialog, that has special helper functions to deal with RCommands. It can be set as the receiver of RCommands, or can be fed RCommands, and will extract any errors associated with those commands. If you use the RKRErrorDialog as a command receiver, be sure to always call deleteThis () instead of delete, so pending commands don't go to a destroyed object. */
+/** A subclass of RKErrorDialog, that has special helper functions to deal with RCommands. It can be set as the receiver of RCommands, or can be fed RCommands, and will extract any errors associated with those commands. */
class RKRErrorDialog : public RKErrorDialog, public RCommandReceiver {
public:
/** constructor. See RKErrorDialog::RKErrorDialog () for details */
@@ -67,7 +67,7 @@
/** constructor. See RKErrorDialog::~RKErrorDialog () for details */
~RKRErrorDialog ();
-/** Use this mechanism to feed RCommands to the RKRErrorDialog manually. The alternative is to simply specify the error-dialog as the receiver of your RCommands (but then you'll never see tehm first). Errors contained in the command will be extracted. */
+/** Use this mechanism to feed RCommands to the RKRErrorDialog manually. The alternative is to simply specify the error-dialog as the receiver of your RCommands (but then you'll never see them first). Errors contained in the command will be extracted. */
void addRCommand (RCommand *command);
protected:
void rCommandDone (RCommand *command);
Modified: trunk/rkward/rkward/rbackend/rcommandreceiver.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rcommandreceiver.cpp 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/rbackend/rcommandreceiver.cpp 2006-11-27 13:59:58 UTC (rev 947)
@@ -2,7 +2,7 @@
rcommandreceiver - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004,2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -20,6 +20,8 @@
RCommandReceiver::RCommandReceiver () {
RK_TRACE (RBACKEND);
+
+ delete_when_done = false;
}
RCommandReceiver::~RCommandReceiver () {
@@ -46,4 +48,16 @@
void RCommandReceiver::delCommand (RCommand *command) {
RK_TRACE (RBACKEND);
outstanding_commands.remove (command);
+
+ if (delete_when_done && outstanding_commands.isEmpty ()) delete this;
}
+
+void RCommandReceiver::autoDeleteWhenDone () {
+ RK_TRACE (RBACKEND);
+
+ if (outstanding_commands.isEmpty ()) {
+ delete this;
+ return;
+ }
+ delete_when_done = true;
+}
Modified: trunk/rkward/rkward/rbackend/rcommandreceiver.h
===================================================================
--- trunk/rkward/rkward/rbackend/rcommandreceiver.h 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/rbackend/rcommandreceiver.h 2006-11-27 13:59:58 UTC (rev 947)
@@ -2,7 +2,7 @@
rcommandreceiver - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004,2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -38,9 +38,11 @@
class RCommandReceiver {
public:
/** constructor. No args */
- RCommandReceiver ();
+ RCommandReceiver ();
/** destructor */
- virtual ~RCommandReceiver ();
+ virtual ~RCommandReceiver ();
+/** Causes the receiver to wait until all outstanding_commands (if any) are finished, then deletes itself */
+ void autoDeleteWhenDone ();
protected:
friend class RCommand;
friend class RInterface;
@@ -54,6 +56,7 @@
protected:
RCommandList outstanding_commands;
private:
+ bool delete_when_done;
void addCommand (RCommand *command);
void delCommand (RCommand *command);
};
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2006-11-27 13:59:58 UTC (rev 947)
@@ -79,10 +79,12 @@
#include "../rkglobals.h"
#include "../rbackend/rinterface.h"
+#include "../misc/rkerrordialog.h"
RKCatchedX11Window::RKCatchedX11Window (WId window_to_embed, int device_number) : RKMDIWindow (0, X11Window) {
RK_TRACE (MISC);
+ error_dialog = new RKRErrorDialog (i18n ("An error occurred"), i18n ("An error occurred"));
part = new RKCatchedX11WindowPart (this);
setFocusPolicy (QWidget::ClickFocus);
@@ -118,6 +120,7 @@
RK_TRACE (MISC);
RKWardApplication::getApp ()->unregisterNameWatcher (embedded);
+ error_dialog->autoDeleteWhenDone ();
}
KParts::Part *RKCatchedX11Window::getPart () {
@@ -215,19 +218,19 @@
void RKCatchedX11Window::activateDevice () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")", RCommand::App, i18n ("Activate graphics device number %1").arg (QString::number (device_number)));
+ RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")", RCommand::App, i18n ("Activate graphics device number %1").arg (QString::number (device_number)), error_dialog);
}
void RKCatchedX11Window::copyDeviceToOutput () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.copy (device=rk.graph.on)\nrk.graph.off ()", RCommand::App | RCommand::DirectToOutput, i18n ("Copy contents of graphics device number %1 to output").arg (QString::number (device_number)));
+ RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.copy (device=rk.graph.on)\nrk.graph.off ()", RCommand::App | RCommand::DirectToOutput, i18n ("Copy contents of graphics device number %1 to output").arg (QString::number (device_number)), error_dialog);
}
void RKCatchedX11Window::printDevice () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.print ()", RCommand::App, i18n ("Print contents of graphics device number %1").arg (QString::number (device_number)));
+ RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.print ()", RCommand::App, i18n ("Print contents of graphics device number %1").arg (QString::number (device_number)), error_dialog);
}
void RKCatchedX11Window::copyDeviceToRObject () {
@@ -249,7 +252,7 @@
void RKCatchedX11Window::duplicateDevice () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.copy (device=x11)", RCommand::App, i18n ("Duplicate graphics device number %1").arg (QString::number (device_number)));
+ RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.copy (device=x11)", RCommand::App, i18n ("Duplicate graphics device number %1").arg (QString::number (device_number)), error_dialog);
}
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h 2006-11-27 13:23:49 UTC (rev 946)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h 2006-11-27 13:59:58 UTC (rev 947)
@@ -80,6 +80,7 @@
class QXEmbedCopy;
class QScrollView;
class QVBox;
+class RKRErrorDialog;
/** An R X11 device window managed by rkward. Should actually be called RKCaughtX11Window... */
class RKCatchedX11Window : public RKMDIWindow {
@@ -128,6 +129,7 @@
QVBox *xembed_container;
QScrollView *scroll_widget;
QVBox *box_widget;
+ RKRErrorDialog *error_dialog;
bool dynamic_size;
KToggleAction *dynamic_size_action;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list