← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3075: disallow premature window closing when the app is under pressure

 

------------------------------------------------------------
revno: 3075
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2012-10-15 18:26:44 +0200
message:
  disallow premature window closing when the app is under pressure
modified:
  win32/MDIChildFrame.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'win32/MDIChildFrame.h'
--- win32/MDIChildFrame.h	2012-06-21 18:52:47 +0000
+++ win32/MDIChildFrame.h	2012-10-15 16:26:44 +0000
@@ -49,7 +49,7 @@
 		BaseType(tabView),
 		lastFocus(NULL),
 		alwaysSameFocus(false),
-		reallyClose(false)
+		closing(false)
 	{
 		typename ThisType::Seed cs;
 		cs.style &= ~WS_VISIBLE;
@@ -155,7 +155,7 @@
 	HWND lastFocus; // last focused widget
 	bool alwaysSameFocus; // always focus the same widget
 
-	bool reallyClose;
+	bool closing;
 
 	void addDlgCodeMessage(ComboBox* widget, bool autoTab = true) {
 		widget->onRaw([=](WPARAM w, LPARAM) { return this->handleGetDlgCode(w, autoTab); }, dwt::Message(WM_GETDLGCODE));
@@ -234,17 +234,17 @@
 	}
 
 	bool handleClosing() {
-		if(reallyClose) {
-			t().postClosing();
-			if(getParent()->getActive() == this) {
-				// Prevent flicker by selecting the next tab - WM_DESTROY would already be too late
-				getParent()->next();
-			}
-			return true;
-		} else if(t().preClosing()) {
-			reallyClose = true;
+		if(!closing && t().preClosing()) {
+			closing = true;
 			// async to make sure all other async calls have been consumed
-			this->callAsync([this] { this->close(true); });
+			this->callAsync([this] {
+				t().postClosing();
+				if(getParent()->getActive() == this) {
+					// Prevent flicker by selecting the next tab - WM_DESTROY would already be too late
+					getParent()->next();
+				}
+				::DestroyWindow(handle());
+			});
 			return false;
 		}
 		return false;