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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Mar 2 15:56:29 UTC 2007


Revision: 1530
          http://svn.sourceforge.net/rkward/?rev=1530&view=rev
Author:   tfry
Date:     2007-03-02 07:56:28 -0800 (Fri, 02 Mar 2007)

Log Message:
-----------
Explicitely initialize RControlWindow, before it may start refreshing.
Not sure, whether it really caused problems before, but this seems cleaner than simply basing on isShown() logic alone.

Modified Paths:
--------------
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/rcontrolwindow.cpp
    trunk/rkward/rkward/windows/rcontrolwindow.h

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2007-03-02 14:58:47 UTC (rev 1529)
+++ trunk/rkward/rkward/rkward.cpp	2007-03-02 15:56:28 UTC (rev 1530)
@@ -185,7 +185,6 @@
 	object_browser = new RObjectBrowser (0, true, "workspace");
 
 	RKGlobals::rcontrol = new RControlWindow (0, true, "rcontrol");		// the control window needs to be initialized before startR () is called.
-	RKGlobals::rcontrol->hide ();		// this line is important! RControlWindow must do some initializations on first show, and be hidden until then.
 
 	RKCommandLog *log = new RKCommandLog (0, true, "Command log");
 	log->setIcon (SmallIcon ("text_block"));	
@@ -221,6 +220,7 @@
 	RKHelpSearchWindow::main_help_search = help_search;
 
 	RKOutputWindow::initialize ();
+	RKGlobals::rcontrol->initialize ();
 
 	if (initial_url) {
 		openWorkspace (*initial_url);

Modified: trunk/rkward/rkward/windows/rcontrolwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rcontrolwindow.cpp	2007-03-02 14:58:47 UTC (rev 1529)
+++ trunk/rkward/rkward/windows/rcontrolwindow.cpp	2007-03-02 15:56:28 UTC (rev 1530)
@@ -66,23 +66,37 @@
 	main_vbox->addWidget (commands_view);
 
 	paused = false;
+	initialized = false;
 }
 
 RControlWindow::~RControlWindow () {
 	RK_TRACE (APP);
 }
 
+bool RControlWindow::isActive () {
+	// don't trace!
+	return (initialized && isShown ());
+}
+
+void RControlWindow::initialize () {
+	RK_TRACE (APP);
+	initialized = true;
+
+	if (isShown ()) show ();	// refreshes the commands
+}
+
 void RControlWindow::show () {
 	RK_TRACE (APP);
 
 	RKMDIWindow::show ();
+	if (!initialized) return;
 	MUTEX_LOCK;
 	refreshCommands ();
 	MUTEX_UNLOCK;
 }
 
 void RControlWindow::addChain (RCommandChain *chain) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	RChainOrCommand *dummy = new RChainOrCommand;
@@ -93,7 +107,7 @@
 }
 
 void RControlWindow::addCommand (RCommand *command, RCommandChain *parent) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	if (!parent) parent = RCommandStack::regular_stack;
@@ -101,7 +115,7 @@
 }
 
 void RControlWindow::updateChain (RCommandChain *chain) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	RControlWindowListViewItem *chainitem = chain_map[chain];
@@ -110,7 +124,7 @@
 }
 
 void RControlWindow::updateCommand (RCommand *command) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	RControlWindowListViewItem *item = command_map[command];
@@ -124,7 +138,7 @@
 }
 
 void RControlWindow::removeCommand (RCommand *command) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	RControlWindowListViewItem *item = command_map[command];
@@ -142,7 +156,7 @@
 }
 
 void RControlWindow::checkCleanChain (RControlWindowListViewItem *chain) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	while (chain && chain->chain_closed && chain->parent () && (!chain->firstChild ())) {
@@ -154,7 +168,7 @@
 }
 
 void RControlWindow::setCommandRunning (RCommand *command) {
-	if (!isShown ()) return;	// do expensive GUI stuff only when visible
+	if (!isActive ()) return;	// do expensive GUI stuff only when visible
 	RK_TRACE (APP);
 
 	RControlWindowListViewItem *item = command_map[command];

Modified: trunk/rkward/rkward/windows/rcontrolwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rcontrolwindow.h	2007-03-02 14:58:47 UTC (rev 1529)
+++ trunk/rkward/rkward/windows/rcontrolwindow.h	2007-03-02 15:56:28 UTC (rev 1530)
@@ -70,6 +70,8 @@
 
 /** 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 ();
+/** Call this once, when the RInterface is ready, and it is ok to try showing commands */
+	void initialize ();
 public slots:
 /** command selection was changed. Automatically select sub-items of selected chains. Enable/disable "Cancel" button */
 	void commandSelectionChanged ();
@@ -98,6 +100,8 @@
 	QMap <RCommandChain *, RControlWindowListViewItem *> chain_map;
 
 	bool paused;
+	bool isActive ();
+	bool initialized;
 };
 
 /**


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