SVN commit 1137173 by staniek: Main Window *fix autoopening (--open) for User Mode *fix possible crash on exit M +8 -5 core/kexipartmanager.cpp M +12 -2 main/KexiMainWindow.cpp M +1 -1 main/KexiMainWindow.h M +1 -1 main/KexiMainWindow_p.h --- trunk/koffice/kexi/core/kexipartmanager.cpp #1137172:1137173 @@ -117,6 +117,8 @@ clearError(); if (!i) return 0; + if (!lookup()) + return 0; if (i->isBroken()) { setError(i->errorMessage()); @@ -175,15 +177,14 @@ Part* Manager::partForClass(const QString &className) { - const QString realClass = realPartClass(className); - Part *p = realClass.isEmpty() ? 0 : m_parts.value(realClass); - if (!p) - setError(i18n("No plugin for class \"%1\"", realClass)); - return p; + Info* info = infoForClass(className); + return part(info); } Info* Manager::infoForClass(const QString &className) { + if (!lookup()) + return 0; const QString realClass = realPartClass(className); Info *i = realClass.isEmpty() ? 0 : m_partsByClass.value(realClass); if (i) @@ -196,6 +197,8 @@ { if (!part) return; + if (!lookup()) + return; // part->info()->setProjectPartID(m_nextTempProjectPartID--); // temp. part id are -1, -2, and so on, m_partlist.append(part->info()); if (!part->info()->partClass().isEmpty()) --- trunk/koffice/kexi/main/KexiMainWindow.cpp #1137172:1137173 @@ -2468,6 +2468,7 @@ if (d->nav) mainWindowGroup.writeEntry("ProjectNavigatorSize", d->nav->parentWidget()->size()); + if (d->propEditorDockableWidget) mainWindowGroup.writeEntry("PropertyEditorSize", d->propEditorDockableWidget->size()); KGlobal::config()->sync(); @@ -4081,12 +4082,21 @@ } #endif -bool KexiMainWindow::openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode) +bool KexiMainWindow::openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode, QString* errorMessage) { + kDebug() << viewMode; //! @todo this can be more complex once we deliver ACLs... if (!d->userMode) return true; KexiPart::Part * part = Kexi::partManager().partForClass(item->partClass()); + if (!part) { + if (errorMessage) { + *errorMessage = Kexi::partManager().errorMsg(); + } + } + kDebug() << part << item->partClass(); + if (part) + kDebug() << item->partClass() << part->supportedUserViewModes(); return part && (part->supportedUserViewModes() & viewMode); } @@ -4104,7 +4114,7 @@ KexiMainWindow::openObject(KexiPart::Item* item, Kexi::ViewMode viewMode, bool &openingCancelled, QMap* staticObjectArgs, QString* errorMessage) { - if (!openingAllowed(item, viewMode)) { + if (!openingAllowed(item, viewMode, errorMessage)) { if (errorMessage) *errorMessage = i18nc( "opening is not allowed in \"data view/design view/text view\" mode", --- trunk/koffice/kexi/main/KexiMainWindow.h #1137172:1137173 @@ -173,7 +173,7 @@ /*! \return true if opening of item \a item in \a viewMode mode is allowed. userMode() is taken into account as well as KexiPart::Part::supportedUserViewModes() for \a item. */ - bool openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode); + bool openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode, QString* errorMessage = 0); //TODO REMOVE? virtual bool eventFilter( QObject *obj, QEvent * e ); --- trunk/koffice/kexi/main/KexiMainWindow_p.h #1137172:1137173 @@ -949,7 +949,7 @@ KexiDockWidget *navDockWidget; KTabWidget *propEditorTabWidget; KexiDockWidget *propEditorDockWidget; - KexiDockableWidget* propEditorDockableWidget; + QPointer propEditorDockableWidget; //! poits to kexi part which has been previously used to setup proppanel's tabs using //! KexiPart::setupCustomPropertyPanelTabs(), in updateCustomPropertyPanelTabs(). QPointer partForPreviouslySetupPropertyPanelTabs;