Commits

equalsraf  committed c46d7e5

Prevent recursive reeize events

- For some time now an elusive SEGFAULT has been crawling
around - it now seems it was a result of a recursive resizeEvent
[QVimShell::resizeEvent -> gui_shell_resize -> (...)resizeEvent ].
- The conditions for this issue usually involve a Vim triggered
resize immediately followed by a external resize - a reproducoble
case is Vim trying to resize in a tiled window manager.
- This commit adds a fix to prevent resizeEvent from triggering a
recursive call - QVimShell::resizeEvent now postpones the call to
guiShellResize(), via a new method VimWrapper::postGuiResizeShell()
- Also I've enabled animations for the main window dock widgets.
* This also changed gui_mch_set_shellsize() to spin the event loop
we really should keep an eye out for regressions around resize/
fullscreen issues.

  • Participants
  • Parent commits facf649

Comments (0)

Files changed (5)

File src/gui_qt.cpp

 	} else {
 		window->resize( new_width, new_height );
 	}
-	gui_resize_shell(vimshell->size().width(), vimshell->size().height());
 
-	// SHOCKING: it seems gui_get_shellsize() updates the proper values for
-	// the columns and rows, after a resize.
-	gui_get_shellsize();
+	//
+	// Spin the loop to handle the resize event. This will
+	// cause gui_resize_shell() to be called
+	gui_mch_update();
 }
 
 /**

File src/qt/mainwindow.cpp

 	setWindowIcon(QIcon(":/icons/vim-qt.png"));
 	setContextMenuPolicy(Qt::PreventContextMenu);
 
-	// We sometimes crash if this is on
-	setAnimated(false);
-
 	// Menu
 	menutoolbar = addToolBar("Menu");
 	menutoolbar->setObjectName("menu");

File src/qt/qvimshell.cpp

 void QVimShell::resizeEvent(QResizeEvent *ev)
 {
 	update();
-	guiResizeShell(ev->size().width(), ev->size().height());
+
+	//
+	// Vim might trigger another resize, postpone the call
+	// to guiResizeShell - otherwise we might be called
+	// recursivelly and crash
+	//
+	postGuiResizeShell(ev->size().width(), ev->size().height());
 }
 
 /**

File src/qt/vimwrapper.cpp

 
 }
 
+/*
+ * Post a vim resize event to be handled later
+ *
+ */
+void VimWrapper::postGuiResizeShell(int w, int h)
+{
+	ResizeEvent *ev = new ResizeEvent( *this, w, h);
+	pendingEvents.append(ev);
+}
+
+/*
+ * Notify Vim of a GUI resize
+ *
+ * If m_processInputOnly is true the handling of this event WILL
+ * be delayed
+ */
 void VimWrapper::guiResizeShell(int w, int h)
 {
 	if ( m_processInputOnly ) {
-		ResizeEvent *ev = new ResizeEvent( *this, w, h);
-		pendingEvents.append(ev);
+		postGuiResizeShell(w, h);
 	} else {
 		gui_resize_shell(w, h);
 	}

File src/qt/vimwrapper.h

 	/**
 	 * Vim methods
 	 */
-	//void guiResizeShell(int, int);
+	void postGuiResizeShell(int w, int h);
 	void guiResizeShell(int w, int h);
 	void guiShellClosed();
 	void guiSendMouseEvent(int , int , int , int , unsigned int );