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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Mar 2 14:47:57 UTC 2007


Revision: 1528
          http://svn.sourceforge.net/rkward/?rev=1528&view=rev
Author:   tfry
Date:     2007-03-02 06:47:57 -0800 (Fri, 02 Mar 2007)

Log Message:
-----------
Fix a problem in RKMDIWindow destruction

Modified Paths:
--------------
    trunk/rkward/TODO
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/rkconsole.h
    trunk/rkward/rkward/robjectbrowser.cpp
    trunk/rkward/rkward/robjectbrowser.h
    trunk/rkward/rkward/windows/rcontrolwindow.cpp
    trunk/rkward/rkward/windows/rcontrolwindow.h
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkcommandlog.cpp
    trunk/rkward/rkward/windows/rkcommandlog.h
    trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
    trunk/rkward/rkward/windows/rkhelpsearchwindow.h
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.h
    trunk/rkward/rkward/windows/rkmdiwindow.cpp
    trunk/rkward/rkward/windows/rkmdiwindow.h

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/TODO	2007-03-02 14:47:57 UTC (rev 1528)
@@ -180,8 +180,6 @@
 	- Spinbox:
 		- find a solution for "pending changes". Currently, if the user enters a value, manually, then presses submit, the old value will be used (the new value is only set, when the focus changes to another widget). Probably the RKSpinbox should emit signals for "pending" and "ready". The plugin spinbox should listen to those and not be satisfied as long as a change is pending. Maybe mark the spinbox in yellow, while a change is pending.
 		- options min_inclusive / max_inclusive for real number spinboxes (defaulting to true)
-	- create grid() plugin
-	- create a (simple) color option plugin (~ 30 colors) for embedding
 	- a function rk.describe.alternative() for use in hypothesis test plugins
 	- use SVG device for graphics output
 	- provide context menu / other UI to export to different formats / edit

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/rkconsole.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -127,9 +127,10 @@
 	hinter = new RKFunctionArgHinter (this, view);
 	
 	setCaption (i18n ("R Console"));
-	part = new RKConsolePart (this);
+	console_part = new RKConsolePart (this);
+	setPart (console_part);
 	initializeActivationSignals ();
-	initializeActions (part->actionCollection ());
+	initializeActions (getPart ()->actionCollection ());
 
 	nprefix = "> ";
 	iprefix = "+ ";
@@ -154,11 +155,6 @@
 	RKSettingsModuleConsole::saveCommandHistory (commands_history);
 }
 
-KParts::Part *RKConsole::getPart () {
-	//RK_TRACE (APP);
-	return part;
-}
-
 void RKConsole::setRHighlighting () {
 	// set syntax-highlighting for R
 	int modes_count = doc->hlModeCount ();
@@ -740,7 +736,7 @@
 	copy_literal_action->setEnabled (hasSelectedText ());
 	run_selection_action->setEnabled (hasSelectedText ());
 
-	part->showPopupMenu (pos);
+	console_part->showPopupMenu (pos);
 
 	run_selection_action->setEnabled (true);
 	copy_literal_action->setEnabled (true);

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/rkconsole.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -77,8 +77,6 @@
 	bool isBusy () { return (current_command || command_incomplete); };
 /** Run a user command (through console, if applicable */
 	static void pipeUserCommand (RCommand *command);
-
-	KParts::Part *getPart ();
 protected:
 /** Handle keystrokes before they reach the kate-part. Return TRUE if we want the kate-part to ignore it
 \param e the QKeyEvent */
@@ -158,7 +156,7 @@
 	void initializeActions (KActionCollection *ac);
 	void pipeCommandThroughConsoleLocal (RCommand *command);
 
-	RKConsolePart *part;
+	RKConsolePart *console_part;
 
 	void doPopupMenu (const QPoint &pos);
 public slots:

Modified: trunk/rkward/rkward/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/robjectbrowser.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/robjectbrowser.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -46,7 +46,7 @@
 
 RObjectBrowser::RObjectBrowser (QWidget *parent, bool tool_window, char *name) : RKMDIWindow (parent, WorkspaceBrowserWindow, tool_window, name) {
 	RK_TRACE (APP);
-	part = new RKDummyPart (0, this);
+	setPart (new RKDummyPart (0, this));
 	initializeActivationSignals ();
 
 	QVBoxLayout *vbox = new QVBoxLayout (this);

Modified: trunk/rkward/rkward/robjectbrowser.h
===================================================================
--- trunk/rkward/rkward/robjectbrowser.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/robjectbrowser.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -43,8 +43,6 @@
 	~RObjectBrowser ();
 
 	enum PopupItems { Help=1, Edit=2, View=3, Rename=4, Copy=5, CopyToGlobalEnv=6, Delete=7 };
-
-	KParts::Part *getPart () { return part; };
 public slots:
 	void updateButtonClicked ();
 	void contextMenuCallback (RKListViewItem *item, bool *suppress);
@@ -65,7 +63,6 @@
 
 	QPushButton *update_button;
 	RKObjectListView *list_view;
-	KParts::Part *part;
 };
 
 /** This class provides a widget to switch quickly between the most important RKObjectListViewSettings */

Modified: trunk/rkward/rkward/windows/rcontrolwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rcontrolwindow.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rcontrolwindow.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -34,8 +34,9 @@
 
 RControlWindow::RControlWindow (QWidget *parent, bool tool_window, char *name) : RKMDIWindow (parent, PendingJobsWindow, tool_window, name) {
 	RK_TRACE (APP);
-	part = new RControlWindowPart (this);
+	setPart (new RControlWindowPart (this));
 	initializeActivationSignals ();
+	setFocusPolicy (QWidget::ClickFocus);
 
 	QVBoxLayout *main_vbox = new QVBoxLayout (this, RKGlobals::marginHint ());
 	QHBoxLayout *button_hbox = new QHBoxLayout (main_vbox, RKGlobals::spacingHint ());
@@ -71,10 +72,6 @@
 	RK_TRACE (APP);
 }
 
-KParts::Part *RControlWindow::getPart () {
-	return part;
-}
-
 void RControlWindow::show () {
 	RK_TRACE (APP);
 

Modified: trunk/rkward/rkward/windows/rcontrolwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rcontrolwindow.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rcontrolwindow.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -68,8 +68,6 @@
 /** Set given command as running. Has no effect unless RControlWindow::isShown ()*/
 	void setCommandRunning (RCommand *command);
 
-	KParts::Part *getPart ();
-
 /** reimplemented to refresh list of commands when showing. This is needed, as the RControlWindow is only kept up to date as long as it is shown. Hence, if it was hidden, and then gets shown, it will have to update the entire list. */
 	void show ();
 public slots:
@@ -99,8 +97,6 @@
 	QMap <RCommand *, RControlWindowListViewItem *> command_map;
 	QMap <RCommandChain *, RControlWindowListViewItem *> chain_map;
 
-	RControlWindowPart *part;
-
 	bool paused;
 };
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -74,6 +74,7 @@
 	RKCommonFunctions::moveContainer (m_doc, "Menu", "tools", "edit", true);
 
 	m_doc->insertChildClient (new RKCommandEditorWindowPart (m_view, this));
+	setPart (m_doc);
 	initializeActivationSignals ();
 	setFocusProxy (m_view);
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -107,7 +107,6 @@
 	void copy ();
 
 	QString getDescription ();
-	KParts::Part *getPart () { return m_doc; };
 
 /** Return current url */
 	KURL url ();

Modified: trunk/rkward/rkward/windows/rkcommandlog.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -57,18 +57,15 @@
 	last_raised_command = 0;
 	command_input_shown = 0;
 
-	part = new RKCommandLogPart (this);
+	setPart (new RKCommandLogPart (this));
 	initializeActivationSignals ();
+	setFocusPolicy (QWidget::ClickFocus);
 }
 
 RKCommandLog::~RKCommandLog(){
 	RK_TRACE (APP);
 }
 
-KParts::Part *RKCommandLog::getPart () {
-	return part;
-}
-
 void RKCommandLog::addInput (RCommand *command) {
 	RK_TRACE (APP);
 	if (!RKSettingsModuleWatch::shouldShowInput (command)) return;

Modified: trunk/rkward/rkward/windows/rkcommandlog.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkcommandlog.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -50,7 +50,6 @@
 	static RKCommandLog *getLog () { return rkcommand_log; };
 
 	RKCommandLogView *getView () { return log_view; };
-	KParts::Part *getPart ();
 protected:
 /** Command has finished. If the command has failed, it may be necessary to print some more information */
 	void rCommandDone (RCommand *command);
@@ -74,7 +73,6 @@
 	int last_raised_command;
 
 	RKCommandLogView *log_view;
-	RKCommandLogPart *part;
 friend class RKWardMainWindow;
 	static RKCommandLog *rkcommand_log;
 };

Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -44,9 +44,9 @@
 
 RKHelpSearchWindow::RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name) : RKMDIWindow (parent, SearchHelpWindow, tool_window, name) {
 	RK_TRACE (APP);
-	part = new RKDummyPart (0, this);
+	setPart (new RKDummyPart (0, this));
+	initializeActivationSignals ();
 	setFocusPolicy (QWidget::ClickFocus);
-	initializeActivationSignals ();
 
 	QVBoxLayout* main_layout = new QVBoxLayout (this, RKGlobals::marginHint (), RKGlobals::spacingHint ());
 	QHBoxLayout* selection_layout = new QHBoxLayout (main_layout, RKGlobals::spacingHint ());

Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -40,8 +40,6 @@
 	RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name=0);
 	~RKHelpSearchWindow ();
 	void rCommandDone (RCommand *command);
-
-	KParts::Part *getPart () { return part; };
 /** small convenience function to get context help for RKCommandEditorWindow and RKConsole.
 @param context_line The current line
 @param cursor_pos cursor position in the current line
@@ -60,7 +58,6 @@
 	QCheckBox* fuzzyCheckBox;
 	QPushButton* findButton;
 	QListView* resultsList;
-	KParts::Part *part;
 friend class RKWardMainWindow;
 	static RKHelpSearchWindow *main_help_search;
 };

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -47,6 +47,7 @@
 	scroll_position=-1;
 	
 	khtmlpart = new KHTMLPart (this, 0, 0, 0, KHTMLPart::BrowserViewGUI);
+	setPart (khtmlpart);
 	initializeActivationSignals ();
 	khtmlpart->setSelectable (true);
 	setFocusProxy (khtmlpart->widget ());
@@ -82,11 +83,6 @@
 	return false;
 }
 
-KParts::Part *RKHTMLWindow::getPart () {
-	RK_TRACE (APP);
-	return khtmlpart;
-}
-
 void RKHTMLWindow::addCommonActions (KActionCollection *action_collection) {
 	RK_TRACE (APP);
 

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -58,7 +58,6 @@
 
 	QString getDescription ();
 	bool isModified ();
-	KParts::Part *getPart ();
 /** Return current url */
 	KURL url ();
 	void doGotoAnchor (const QString &anchor_name);

Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp	2007-03-02 14:47:57 UTC (rev 1528)
@@ -33,10 +33,13 @@
 	if (tool_window) state = ToolWindow;
 	else state = Attached;
 	wrapper = 0;
+	part = 0;
 }
 
 RKMDIWindow::~RKMDIWindow () {
 	RK_TRACE (APP);
+
+	qDebug ("off");
 }
 
 //virtual
@@ -109,16 +112,16 @@
 }
 
 bool RKMDIWindow::eventFilter (QObject *watched, QEvent *e) {
-	//RK_TRACE (APP);
+	// WARNING: The derived object and the part may both the destroyed at this point of time!
+	// Make sure not to call any virtual function on this object!
 
 	RK_ASSERT (watched == getPart ());
 	if (KParts::PartActivateEvent::test (e)) {
+		RK_TRACE (APP);		// trace only the "interesting" calls to this function
+
 		KParts::PartActivateEvent *ev = static_cast<KParts::PartActivateEvent *> (e);
 		if (ev->activated ()) {
 			emit (windowActivated (this));
-			qDebug ("activated: %s", getDescription ().latin1 ());
-		} else {
-			qDebug ("deactivated: %s", getDescription ().latin1 ());
 		}
 	}
 	return FALSE;

Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h	2007-03-02 07:43:12 UTC (rev 1527)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h	2007-03-02 14:47:57 UTC (rev 1528)
@@ -64,7 +64,7 @@
 /** @returns A short caption (e.g. only the filename without the path). Default implementation simply calls QWidget::caption () */
 	virtual QString shortCaption ();
 /** @returns The corresponding KPart for this window */
-	virtual KParts::Part *getPart () = 0;
+	KParts::Part *getPart () { return part; };
 /** This is used in RKWorkplace::saveWorkplace () to save the info about the workplace. Make sure to add corresponding code to RKWorkplace::restoreWorkplace (), so your window(s) get restored when loading a Workspace
 @returns An internal descriptive string. */
 	virtual QString getDescription () { return QString (); };
@@ -94,12 +94,14 @@
 /** This signal is emitted, when the window was activated *with* focus */
 	void windowActivated (RKMDIWindow *);
 protected:
+	void setPart (KParts::Part *p) { part = p; };
 	void initializeActivationSignals ();
 friend class RKWorkplace;
 /** type of this window */
 	Type type;
 private:
 /** state of this window (attached / detached). This is usually set from the RKWorkplace */
+	KParts::Part *part;
 	State state;
 	KMdiToolViewAccessor *wrapper;
 };


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