Commit 221f59e1 authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: modernize code

 - no behavior changes
 - moved a slot to a lambda
 - Using QPointer instead of raw pointer to trigger
   assert if dangling pointer is accessed.
   Refactoring the code might accidentally trigger a
   delete of the QWidget.

Change-Id: Idf711da92e13cf81dd718ae9e034bca7f6d26220
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent cacdcf71
...@@ -123,20 +123,17 @@ QList<QToolButton *> DesignerSideBarItem::createToolBarWidgets() ...@@ -123,20 +123,17 @@ QList<QToolButton *> DesignerSideBarItem::createToolBarWidgets()
} }
// ---------- DesignModeWidget // ---------- DesignModeWidget
DesignModeWidget::DesignModeWidget(QWidget *parent) : DesignModeWidget::DesignModeWidget(QWidget *parent)
QWidget(parent), : QWidget(parent)
m_mainSplitter(0), , m_toolBar(new Core::EditorToolBar(this))
m_toolBar(new Core::EditorToolBar(this)), , m_crumbleBar(new CrumbleBar(this))
m_crumbleBar(new CrumbleBar(this)),
m_isDisabled(false),
m_showSidebars(true),
m_initStatus(NotInitialized),
m_warningWidget(0),
m_navigatorHistoryCounter(-1),
m_keepNavigatorHistory(false)
{ {
connect(viewManager().nodeInstanceView(), &NodeInstanceView::qmlPuppetCrashed, connect(viewManager().nodeInstanceView(), &NodeInstanceView::qmlPuppetCrashed,
this, &DesignModeWidget::showQmlPuppetCrashedError); [=]() {
RewriterError error(tr("Qt Quick emulation layer crashed"));
updateErrorStatus(QList<RewriterError>() << error);
}
);
} }
DesignModeWidget::~DesignModeWidget() DesignModeWidget::~DesignModeWidget()
...@@ -275,9 +272,9 @@ void DesignModeWidget::setup() ...@@ -275,9 +272,9 @@ void DesignModeWidget::setup()
QList<Core::INavigationWidgetFactory *> factories = QList<Core::INavigationWidgetFactory *> factories =
ExtensionSystem::PluginManager::getObjects<Core::INavigationWidgetFactory>(); ExtensionSystem::PluginManager::getObjects<Core::INavigationWidgetFactory>();
QWidget *openDocumentsWidget = 0; QWidget *openDocumentsWidget = nullptr;
QWidget *projectsExplorer = 0; QWidget *projectsExplorer = nullptr;
QWidget *fileSystemExplorer = 0; QWidget *fileSystemExplorer = nullptr;
foreach (Core::INavigationWidgetFactory *factory, factories) { foreach (Core::INavigationWidgetFactory *factory, factories) {
Core::NavigationView navigationView; Core::NavigationView navigationView;
...@@ -414,16 +411,6 @@ void DesignModeWidget::setup() ...@@ -414,16 +411,6 @@ void DesignModeWidget::setup()
show(); show();
} }
void DesignModeWidget::showQmlPuppetCrashedError()
{
QList<RewriterError> errorList;
RewriterError error(tr("Qt Quick emulation layer crashed"));
errorList.append(error);
disableWidgets();
showMessageBox(errorList);
}
void DesignModeWidget::toolBarOnGoBackClicked() void DesignModeWidget::toolBarOnGoBackClicked()
{ {
if (m_navigatorHistoryCounter > 0) { if (m_navigatorHistoryCounter > 0) {
......
...@@ -89,8 +89,6 @@ public slots: ...@@ -89,8 +89,6 @@ public slots:
void toggleRightSidebar(); void toggleRightSidebar();
private slots: private slots:
void showQmlPuppetCrashedError();
void toolBarOnGoBackClicked(); void toolBarOnGoBackClicked();
void toolBarOnGoForwardClicked(); void toolBarOnGoForwardClicked();
...@@ -107,21 +105,21 @@ private: // functions ...@@ -107,21 +105,21 @@ private: // functions
private: // variables private: // variables
QSplitter *m_mainSplitter = nullptr; QSplitter *m_mainSplitter = nullptr;
DocumentWarningWidget *m_warningWidget = nullptr; QPointer<DocumentWarningWidget> m_warningWidget;
QScopedPointer<Core::SideBar> m_leftSideBar; QScopedPointer<Core::SideBar> m_leftSideBar;
QScopedPointer<Core::SideBar> m_rightSideBar; QScopedPointer<Core::SideBar> m_rightSideBar;
QPointer<QWidget> m_topSideBar; QPointer<QWidget> m_topSideBar;
Core::EditorToolBar *m_toolBar; Core::EditorToolBar *m_toolBar;
CrumbleBar *m_crumbleBar; CrumbleBar *m_crumbleBar;
bool m_isDisabled; bool m_isDisabled = false;
bool m_showSidebars; bool m_showSidebars = true;
InitializeStatus m_initStatus; InitializeStatus m_initStatus = NotInitialized;
QStringList m_navigatorHistory; QStringList m_navigatorHistory;
int m_navigatorHistoryCounter; int m_navigatorHistoryCounter = -1;
bool m_keepNavigatorHistory; bool m_keepNavigatorHistory = false;
QList<QPointer<QWidget> >m_viewWidgets; QList<QPointer<QWidget> >m_viewWidgets;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment