[Scummvm-cvs-logs] scummvm-tools master -> d02758eef0f32c56876cdd39c89a396332a83d4f

criezy criezy at scummvm.org
Tue Nov 27 04:19:01 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-tools' repo located at https://github.com/scummvm/scummvm-tools .

Summary:
d02758eef0 TOOLS: Fix crash when compiling with wxWidgets 2.9


Commit: d02758eef0f32c56876cdd39c89a396332a83d4f
    https://github.com/scummvm/scummvm-tools/commit/d02758eef0f32c56876cdd39c89a396332a83d4f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2012-11-26T19:18:04-08:00

Commit Message:
TOOLS: Fix crash when compiling with wxWidgets 2.9

The issue occurred on the Intro page when clicking on the Compress,
Extract or Advanced button. The page and therefore the buttons were
destroyed from the event handler of the button that was clicked. While
this work with wxWidgets 2.8 this seems dangerous. And this caused
a crash with wxWidgets 2.9 (at least on mac-cocoa). The page deletion
is now delayed.

Changed paths:
    NEWS
    gui/main.cpp
    gui/main.h



diff --git a/NEWS b/NEWS
index b0db8cf..13fbaa6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,8 @@
 For a more comprehensive changelog of the latest experimental code, see:
         https://github.com/scummvm/scummvm-tools/commits/
 
-1.5.0 (????-??-??)
+1.6.0 (????-??-??)
+ - Fix crash when compiling with wxWidgets 2.9.
  - Add two tools to extract and repackage the Soltys game data.
  - Fix bug #3093138: "compress_tucker with ScummVM CLI Tools not working".
  - Fix bug #3280674: "ScummTools do not compress monster.sou of german fdd-version"
diff --git a/gui/main.cpp b/gui/main.cpp
index e07e134..1850da5 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -226,6 +226,9 @@ ScummToolsFrame::ScummToolsFrame(const wxString &title, const wxPoint &pos, cons
 	_buttons = new WizardButtons(main, linetext, _configuration);
 	sizer->Add(_buttons, wxSizerFlags().Border().Center().Expand());
 
+	// Delete old panels on idle event
+	Connect(wxEVT_IDLE, wxIdleEventHandler(ScummToolsFrame::destroyOldPanels), NULL, this);
+
 	main->SetSizer(sizer);
 }
 
@@ -236,6 +239,9 @@ ScummToolsFrame::~ScummToolsFrame() {
 
 	for (std::vector<WizardPage *>::iterator iter = _pages.begin(); iter != _pages.end(); ++iter)
 		delete *iter;
+
+	for (std::vector<wxWindow *>::iterator iter = _oldPanels.begin(); iter != _oldPanels.end(); ++iter)
+		delete *iter;
 }
 
 void ScummToolsFrame::CreateMenuBar() {
@@ -288,9 +294,15 @@ void ScummToolsFrame::switchPage(WizardPage *next, SwitchToPage page) {
 		break;
 	}
 
-	if (oldPanel)
+	if (oldPanel) {
 		// Destroy the old page
-		oldPanel->Destroy();
+		// oldPanel->Destroy();
+		// We have an issue here for the intro page. This is called from the event handler of buttons on the panel
+		// (the Compress, Extract or Advanced button). So we cannot delete the oldPanel now (that would cause a crash).
+		// Instead we hide the panel and it will be deleted later (on the next Idel Event).
+		oldPanel->Hide();
+		_oldPanels.push_back(oldPanel);
+	}
 
 	wxWindow *newPanel = _pages.back()->CreatePanel(_wizardpane);
 
@@ -306,6 +318,13 @@ void ScummToolsFrame::switchPage(WizardPage *next, SwitchToPage page) {
 	_buttons->setPage(_pages.back(), newPanel);
 }
 
+void ScummToolsFrame::destroyOldPanels(wxIdleEvent &) {
+	while (!_oldPanels.empty()) {
+		delete _oldPanels.back();
+		_oldPanels.pop_back();
+	}
+}
+
 wxString ScummToolsFrame::GetHelpText() {
 	return _pages.back()->getHelp();
 }
diff --git a/gui/main.h b/gui/main.h
index a884d68..936d2a8 100644
--- a/gui/main.h
+++ b/gui/main.h
@@ -115,8 +115,6 @@ public:
 	void onMenuAbout(wxCommandEvent &evt);
 	void onMenuExit(wxCommandEvent &evt);
 
-
-
 	/** The state of the wizard so far */
 	Configuration _configuration;
 
@@ -125,10 +123,13 @@ public:
 private:
 	enum SwitchToPage { NextPage, PreviousPage, FirstPage };
 	void switchPage(WizardPage *nextPage, SwitchToPage page);
+    
+	void destroyOldPanels(wxIdleEvent &evt);
 
 	wxPanel *_wizardpane;
 
 	std::vector<WizardPage *> _pages;
+	std::vector<wxWindow *> _oldPanels;
 
 	DECLARE_EVENT_TABLE()
 };






More information about the Scummvm-git-logs mailing list