From kde-commits Tue Jul 12 14:05:10 2005 From: Michael Buesch Date: Tue, 12 Jul 2005 14:05:10 +0000 To: kde-commits Subject: branches/stable/extragear/security/pwmanager/pwmanager Message-Id: <1121177110.263756.5362.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=112117712717994 SVN commit 433994 by mbuesch: fix crashes with non-available mainwindow, by getting rid of the PwMDocUi::currentView pointer. M +0 -1 masterkey/masterkey.cpp M +0 -1 masterkey/smartkey/smartkey.cpp M +8 -4 masterkey/smartkey/smartkey_backend.cpp M +1 -2 pwmdocui.cpp M +3 -10 pwmdocui.h M +7 -0 pwminit.cpp M +1 -2 pwminit.h M +0 -1 pwmview.cpp --- branches/stable/extragear/security/pwmanager/pwmanager/masterkey/masterkey.cpp #433993:433994 @@ -25,7 +25,6 @@ MasterKey::MasterKey(QWidget *_parent) : parent (_parent) { - PWM_ASSERT(parent); } MasterKey::~MasterKey() --- branches/stable/extragear/security/pwmanager/pwmanager/masterkey/smartkey/smartkey.cpp #433993:433994 @@ -26,7 +26,6 @@ : parent (_parent) , mainwnd (_mainwnd) { - PWM_ASSERT(parent); backend = new SmartKey_backend(this); } --- branches/stable/extragear/security/pwmanager/pwmanager/masterkey/smartkey/smartkey_backend.cpp #433993:433994 @@ -176,11 +176,13 @@ { if (QCString(msg) == QCString(IPC_MSG_OWW_SHOW)) { openWaitWnd->show(); - sk->parent->setEnabled(false); + if (sk->parent) + sk->parent->setEnabled(false); openWaitWnd->setEnabled(true); goto oww_set_timeout; } else if (QCString(msg) == QCString(IPC_MSG_OWW_HIDE)) { - sk->parent->setEnabled(true); + if (sk->parent) + sk->parent->setEnabled(true); openWaitWnd->hide(); } else if (QCString(msg) == QCString(IPC_MSG_OWW_PROGRESS)) { PWM_ASSERT(openWaitWndCnt > 0); @@ -190,10 +192,12 @@ goto oww_set_timeout; } else if (QCString(msg) == QCString(IPC_MSG_AWW_SHOW)) { accessWaitWnd->show(); - sk->parent->setEnabled(false); + if (sk->parent) + sk->parent->setEnabled(false); accessWaitWnd->setEnabled(true); } else if (QCString(msg) == QCString(IPC_MSG_AWW_HIDE)) { - sk->parent->setEnabled(true); + if (sk->parent) + sk->parent->setEnabled(true); accessWaitWnd->hide(); } else BUG(); --- branches/stable/extragear/security/pwmanager/pwmanager/pwmdocui.cpp #433993:433994 @@ -25,7 +25,6 @@ PwMDocUi::PwMDocUi(QObject *parent, const char *name) : QObject(parent, name) { - currentView = 0; } PwMDocUi::~PwMDocUi() @@ -129,7 +128,7 @@ } QString fn(KFileDialog::getSaveFileName(QString(), i18n("*.pwm|PwManager Password file"), - currentView)); + getCurrentView())); if (fn == "") { doc->timer()->putLock(DocTimer::id_autoLockTimer); return false; --- branches/stable/extragear/security/pwmanager/pwmanager/pwmdocui.h #433993:433994 @@ -12,6 +12,8 @@ #ifndef __PWMDOCUI_H #define __PWMDOCUI_H +#include "pwminit.h" + #include #include @@ -46,14 +48,9 @@ PwMDocUi(QObject* parent = 0, const char *name = 0); ~PwMDocUi(); - /** when a new view is activated, call this to - * inform the Master-password-layer about this. - */ - void setCurrentView(QWidget *view) - { currentView = view; } /** return the currentView pointer */ QWidget* getCurrentView() - { return currentView; } + { return PwMInit::curWidget(); } /** saves the document (with user dialog) */ bool saveDocUi(PwMDoc *doc); /** save as (with user dialog) */ @@ -76,10 +73,6 @@ void gpmPwLenErrMsgBox(); /** ask for saving */ int dirtyAskSave(const QString &docTitle); - -private: - /** the currently active view */ - QWidget *currentView; }; #endif --- branches/stable/extragear/security/pwmanager/pwmanager/pwminit.cpp #433993:433994 @@ -163,6 +163,13 @@ */ } +QWidget * PwMInit::curWidget() +{ + if (!sig_init_pointer) + return 0; + return sig_init_pointer->_curWidget; +} + void PwMInit::initPosixSignalHandler() { signal(SIGINT, sig_handler); --- branches/stable/extragear/security/pwmanager/pwmanager/pwminit.h #433993:433994 @@ -91,8 +91,7 @@ void shutdownApp(int exitStatus); /** returns a pointer to the current widget */ - QWidget * curWidget() - { return _curWidget; } + static QWidget * curWidget(); /** returns a pointer to the dcop client */ DCOPClient * dcopClient() { return _dcopClient; } --- branches/stable/extragear/security/pwmanager/pwmanager/pwmview.cpp #433993:433994 @@ -46,7 +46,6 @@ resize(_mainClass->size()); initStyle(conf()->confWndMainViewStyle()); initCtxMenu(); - doc->setCurrentView(this); connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); }