On Tue, 2005-05-10 at 10:35, Lars Gullik BjÃnnes wrote:
> Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> I think this looks good, if you can get somebody else to test it to
> verify your claims :-) then it should be committed.
> 
> But please just get rid of the commented "processEvente"s.

I will commit the attached a bit later. It appears that the only bug
found was Georg's reported scrollbar failure in the math panel, for
which we agreed another solution must exist.

(And then there is the weirdness of keystrokes "jumping the queue"; but
then, is there any guarantee in X that non-processed events are kept in
temporal order?)

- Martin

Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2177
diff -u -p -r1.2177 ChangeLog
--- ChangeLog	9 May 2005 17:29:20 -0000	1.2177
+++ ChangeLog	11 May 2005 07:11:21 -0000
@@ -1,3 +1,8 @@
+2005-05-11  Martin Vermeer  <[EMAIL PROTECTED]>
+
+	* BufferView_pimpl.C (update): fix processEvents -caused update
+	recursion bug
+
 2005-05-09  Georg Baum  <[EMAIL PROTECTED]>
 
 	* cursor.h (undispatched, noUpdate): add comments from André
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.582
diff -u -p -r1.582 BufferView_pimpl.C
--- BufferView_pimpl.C	8 May 2005 10:02:35 -0000	1.582
+++ BufferView_pimpl.C	11 May 2005 07:11:21 -0000
@@ -617,12 +617,20 @@ void BufferView::Pimpl::update(bool fitc
 	if (buffer_) {
 		// Update macro store
 		buffer_->buildMacros();
-		// First drawing step
 
 		CoordCache backup;
 		std::swap(theCoords, backup);
+		
+		// This call disallows cursor blink to call
+		// processEvents. It is necessary to prevent screen
+		// redraw being called recursively.
+		screen().unAllowSync();
+		// This, together with doneUpdating(), verifies (using
+		// asserts) that screen redraw is not called from 
+		// within itself.
 		theCoords.startUpdating();
 
+		// First drawing step
 		ViewMetricsInfo vi = metrics();
 
 		if (fitcursor && fitCursor()) {
@@ -633,7 +641,8 @@ void BufferView::Pimpl::update(bool fitc
 			// Second drawing step
 			screen().redraw(*bv_, vi);
 		} else {
-			// Abort updating of the coord cache - just restore the old one
+			// Abort updating of the coord
+			// cache - just restore the old one
 			std::swap(theCoords, backup);
 		}
 	} else
Index: frontends/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ChangeLog,v
retrieving revision 1.278
diff -u -p -r1.278 ChangeLog
--- frontends/ChangeLog	26 Apr 2005 11:12:15 -0000	1.278
+++ frontends/ChangeLog	11 May 2005 07:11:21 -0000
@@ -1,3 +1,8 @@
+2005-05-11  Martin Vermeer  <[EMAIL PROTECTED]>
+
+	* screen.[hC]: fix processEvents -caused screen update recursion
+	bug
+
 2005-04-25  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* LyXView.C:
Index: frontends/screen.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.C,v
retrieving revision 1.101
diff -u -p -r1.101 screen.C
--- frontends/screen.C	11 Feb 2005 18:07:06 -0000	1.101
+++ frontends/screen.C	11 May 2005 07:11:21 -0000
@@ -122,7 +122,7 @@ SplashScreen::SplashScreen()
 
 
 LyXScreen::LyXScreen()
-	: greyed_out_(true), cursor_visible_(false)
+	: greyed_out_(true), cursor_visible_(false), sync_allowed_(true)
 {
 	// Start loading the pixmap as soon as possible
 	if (lyxrc.show_banner) {
@@ -147,15 +147,19 @@ void LyXScreen::checkAndGreyOut()
 
 void LyXScreen::showCursor(BufferView & bv)
 {
-	// You are not expected to understand this. This forces Qt
-	// (the problem case) to deal with its event queue. This is
-	// necessary when holding down a key such as 'page down' or
-	// just typing: without this processing of the event queue,
-	// the cursor gets ahead of itself without a selection or
-	// workarea redraw having a chance to keep up. If you think
-	// you can remove this, try selecting text with the mouse
-	// in Qt, or holding Page Down on the User's Guide.
-	lyx_gui::sync_events();
+	// This code is currently meaningful only for the Qt frontend.
+	// This is the place (like below in hideCursor) where
+	// processEvents is being called, and things like keystrokes and
+	// mouse clicks are being handed to the LyX core, once every 
+	// cursor blink. 
+	// THERE IS NOT SUPPOSED TO BE ANY OTHER CALL TO processEvents 
+	// ANYWHERE ELSE.
+	// in BufferView::Pimpl::update() and here, the sync_allowed_
+	// guard is set/cleared which is used here to prevent recursive
+	// calls to screen update. startUpdating() and doneUpdating() in
+	// coordcache again contain asserts to detect such recursion.
+	if (sync_allowed_)
+		lyx_gui::sync_events();
 
 	if (cursor_visible_)
 		return;
@@ -202,6 +206,9 @@ void LyXScreen::showCursor(BufferView & 
 
 void LyXScreen::hideCursor()
 {
+	if (sync_allowed_)
+		lyx_gui::sync_events();
+
 	if (!cursor_visible_)
 		return;
 
@@ -223,13 +230,12 @@ void LyXScreen::redraw(BufferView & bv, 
 {
 	greyed_out_ = false;
 	workarea().getPainter().start();
-	hideCursor();
 	paintText(bv, vi);
 	lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
 	expose(0, 0, workarea().workWidth(), workarea().workHeight());
 	workarea().getPainter().end();
 	theCoords.doneUpdating();
-	showCursor(bv);
+	sync_allowed_ = true;
 }
 
 
Index: frontends/screen.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/screen.h,v
retrieving revision 1.30
diff -u -p -r1.30 screen.h
--- frontends/screen.h	30 Nov 2004 01:59:46 -0000	1.30
+++ frontends/screen.h	11 May 2005 07:11:21 -0000
@@ -54,6 +54,9 @@ public:
 	/// toggle the cursor's visibility
 	void toggleCursor(BufferView & bv);
 
+	///
+	void unAllowSync() { sync_allowed_ = false; };
+
 protected:
 	/// cause the display of the given area of the work area
 	virtual void expose(int x, int y, int w, int h) = 0;
@@ -86,6 +89,9 @@ private:
 
 	/// is the cursor currently displayed
 	bool cursor_visible_;
+
+	///
+	bool sync_allowed_;
 };
 
 #endif // SCREEN_H
Index: frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.772
diff -u -p -r1.772 ChangeLog
--- frontends/qt2/ChangeLog	7 May 2005 12:12:23 -0000	1.772
+++ frontends/qt2/ChangeLog	11 May 2005 07:11:22 -0000
@@ -1,3 +1,11 @@
+2005-05-11  Martin Vermeer  <[EMAIL PROTECTED]>
+
+	* lyx_gui.C (sync_events):
+	* QDialogView.h (update, build):
+	* QLPopupMenu.C (fire):
+	* QMathDialog.C (resizeEvent, showingPanel): fix processEvent
+	-caused update recursion bug
+
 2005-05-06  Michael Schmitt  <[EMAIL PROTECTED]>
 
 	* ui/*.ui: remove captions: they are unused and pollute the po
Index: frontends/qt2/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.80
diff -u -p -r1.80 lyx_gui.C
--- frontends/qt2/lyx_gui.C	10 Jan 2005 19:17:41 -0000	1.80
+++ frontends/qt2/lyx_gui.C	11 May 2005 07:11:22 -0000
@@ -252,6 +252,10 @@ void start(string const & batch, vector<
 
 void sync_events()
 {
+	// This is the ONLY place where processEvents may be called.
+	// During screen update/ redraw, this method is disabled to 
+	// prevent keyboard events being handed to the LyX core, where
+	// they could cause re-entrant calls to screen update.
 	qApp->processEvents();
 }
 
Index: frontends/qt2/QDialogView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QDialogView.h,v
retrieving revision 1.12
diff -u -p -r1.12 QDialogView.h
--- frontends/qt2/QDialogView.h	26 Apr 2005 11:12:18 -0000	1.12
+++ frontends/qt2/QDialogView.h	11 May 2005 07:11:22 -0000
@@ -126,10 +126,8 @@ void QView<GUIDialog>::update()
 
 	// protect the BC from unwarranted state transitions
 
-	qApp->processEvents();
 	updating_ = true;
 	update_contents();
-	qApp->processEvents();
 	updating_ = false;
 
 	form()->setUpdatesEnabled(true);
@@ -142,10 +140,8 @@ void QView<GUIDialog>::build()
 {
 	// protect the BC from unwarranted state transitions
 
-	qApp->processEvents();
 	updating_ = true;
 	build_dialog();
-	qApp->processEvents();
 	updating_ = false;
 }
 
Index: frontends/qt2/QLPopupMenu.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPopupMenu.C,v
retrieving revision 1.38
diff -u -p -r1.38 QLPopupMenu.C
--- frontends/qt2/QLPopupMenu.C	16 Nov 2004 10:46:22 -0000	1.38
+++ frontends/qt2/QLPopupMenu.C	11 May 2005 07:11:22 -0000
@@ -88,7 +88,6 @@ QLPopupMenu::QLPopupMenu(QLMenubar * own
 
 void QLPopupMenu::fire(int index)
 {
-	qApp->processEvents();
 #ifdef Q_WS_MACX
 	if (index >= indexOffset) {
 		MenuItem mi = owner_->backend().getMenu("LyX")[index - indexOffset];
Index: frontends/qt2/QMathDialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QMathDialog.C,v
retrieving revision 1.41
diff -u -p -r1.41 QMathDialog.C
--- frontends/qt2/QMathDialog.C	2 Jun 2004 20:13:18 -0000	1.41
+++ frontends/qt2/QMathDialog.C	11 May 2005 07:11:22 -0000
@@ -52,8 +52,7 @@ protected:
 			return;
 
 		w_->resize(viewport()->width(), w_->height());
-		// force the resize to get accurate scrollbars
-		qApp->processEvents();
+		// force the resize to get accurate scrollbar
 		resizeContents(w_->width(), w_->height());
 	}
 private:
@@ -155,9 +154,6 @@ void QMathDialog::showingPanel(int num)
 		return;
 
 	addPanel(num);
-
-	// Qt needs to catch up. Dunno why.
-	qApp->processEvents();
 
 	panel_initialised[num] = true;
 }

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to