Author: sh-sh-sh
Date: Wed Jun 11 20:18:24 2008
New Revision: 48248
URL: http://svn.opensuse.org/viewcvs/yast?rev=48248&view=rev
Log:
Introduced YUITerminator to make sure the UI is properly shut
down in all cases, regardless if called from YCP or plain C++
Modified:
trunk/libyui/VERSION
trunk/libyui/package/yast2-libyui.changes
trunk/libyui/src/YUI.cc
trunk/libyui/src/YUI.h
Modified: trunk/libyui/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/VERSION?rev=48248&r1=48247&r2=48248&view=diff
==============================================================================
--- trunk/libyui/VERSION (original)
+++ trunk/libyui/VERSION Wed Jun 11 20:18:24 2008
@@ -1 +1 @@
-2.16.48
+2.17.1
Modified: trunk/libyui/package/yast2-libyui.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/package/yast2-libyui.changes?rev=48248&r1=48247&r2=48248&view=diff
==============================================================================
--- trunk/libyui/package/yast2-libyui.changes (original)
+++ trunk/libyui/package/yast2-libyui.changes Wed Jun 11 20:18:24 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Jun 11 19:49:36 CEST 2008 - sh@suse.de
+
+- Introduced YUITerminator to make sure the UI is properly shut
+ down in all cases, regardless if called from YCP or plain C++
+- V 2.17.1
+
+-------------------------------------------------------------------
Wed May 28 14:31:31 CEST 2008 - sh@suse.de
- Added YWizard::wizardMode() for bnc #393040
Modified: trunk/libyui/src/YUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUI.cc?rev=48248&r1=48247&r2=48248&view=diff
==============================================================================
--- trunk/libyui/src/YUI.cc (original)
+++ trunk/libyui/src/YUI.cc Wed Jun 11 20:18:24 2008
@@ -12,10 +12,7 @@
File: YUI.cc
- Authors: Stefan Hundhammer
- Stanislav Visnovsky
-
- Maintainer: Stefan Hundhammer
+ Author: Stefan Hundhammer
/-*/
@@ -43,6 +40,7 @@
YUI * YUI::_ui = 0;
+static bool uiDeleted = false;
extern void * start_ui_thread( void * yui );
@@ -61,23 +59,29 @@
YUI::~YUI()
{
- if ( _withThreads && _uiThread )
+ if ( _ui )
{
- yuiError() << "shutdownThreads() was never called!" << endl;
- yuiError() << "shutting down now - this might segfault" << endl;
- shutdownThreads();
- }
+ if ( _withThreads && _uiThread )
+ {
+ yuiError() << "shutdownThreads() was never called!" << endl;
+ yuiError() << "shutting down now - this might segfault" << endl;
+ shutdownThreads();
+ }
- if ( YDialog::openDialogsCount() > 0 )
- yuiError() << YDialog::openDialogsCount() << " open dialogs left over" << endl;
+ if ( YDialog::openDialogsCount() > 0 )
+ yuiError() << YDialog::openDialogsCount() << " open dialogs left over" << endl;
- if ( _builtinCaller )
- delete _builtinCaller;
+ if ( _builtinCaller )
+ delete _builtinCaller;
- YDialog::deleteAllDialogs();
+ YDialog::deleteAllDialogs();
- YMacro::deleteRecorder();
- YMacro::deletePlayer();
+ YMacro::deleteRecorder();
+ YMacro::deletePlayer();
+
+ _ui = 0;
+ uiDeleted = true;
+ }
}
@@ -146,11 +150,13 @@
if ( _ui )
return;
+ if ( uiDeleted )
+ YUI_THROW( YUIException( "UI already deleted" ) );
+
YUILoader::loadUI();
}
-
void YUI::topmostConstructorHasFinished()
{
// The ui thread must not be started before the constructor
@@ -353,8 +359,9 @@
}
+//
// ----------------------------------------------------------------------
-
+//
void * start_ui_thread( void * yui )
{
@@ -370,5 +377,51 @@
}
+//
+// ----------------------------------------------------------------------
+//
+
+
+/**
+ * Helper class to make sure the UI is properly shut down.
+ **/
+class YUITerminator
+{
+public:
+ YUITerminator() {}
+
+ /**
+ * Destructor.
+ *
+ * If there still is a UI, it will be deleted.
+ * If there is none, this will do nothing.
+ **/
+ ~YUITerminator();
+};
+
+
+YUITerminator::~YUITerminator()
+{
+ if ( YUI::_ui )
+ {
+ yuiMilestone() << "Shutting down UI" << endl;
+ delete YUI::_ui;
+
+ YUI::_ui = 0;
+ }
+}
+
+
+/**
+ * Static YUITerminator instance: It will make sure the UI is deleted in its
+ * global destructor. If the UI is already destroyed, it will do nothing. If
+ * there still is a UI object, it will be deleted.
+ *
+ * This is particularly important for the NCurses UI so the terminal settings
+ * are properly restored.
+ **/
+static YUITerminator uiTerminator;
+
+
// EOF
Modified: trunk/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YUI.h?rev=48248&r1=48247&r2=48248&view=diff
==============================================================================
--- trunk/libyui/src/YUI.h (original)
+++ trunk/libyui/src/YUI.h Wed Jun 11 20:18:24 2008
@@ -43,6 +43,7 @@
class YUI
{
friend class YUIFunction;
+ friend class YUITerminator;
protected:
/**
@@ -114,8 +115,9 @@
**/
static void ensureUICreated();
-
+
protected:
+
/**
* Create the widget factory that provides all the createXY() methods for
* standard (mandatory, i.e. non-optional) widgets.
@@ -140,6 +142,7 @@
**/
virtual YApplication * createApplication() = 0;
+
public:
/**
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org