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()
}
// ---------- DesignModeWidget
DesignModeWidget::DesignModeWidget(QWidget *parent) :
QWidget(parent),
m_mainSplitter(0),
m_toolBar(new Core::EditorToolBar(this)),
m_crumbleBar(new CrumbleBar(this)),
m_isDisabled(false),
m_showSidebars(true),
m_initStatus(NotInitialized),
m_warningWidget(0),
m_navigatorHistoryCounter(-1),
m_keepNavigatorHistory(false)
DesignModeWidget::DesignModeWidget(QWidget *parent)
: QWidget(parent)
, m_toolBar(new Core::EditorToolBar(this))
, m_crumbleBar(new CrumbleBar(this))
{
connect(viewManager().nodeInstanceView(), &NodeInstanceView::qmlPuppetCrashed,
this, &DesignModeWidget::showQmlPuppetCrashedError);
[=]() {
RewriterError error(tr("Qt Quick emulation layer crashed"));
updateErrorStatus(QList<RewriterError>() << error);
}
);
}
DesignModeWidget::~DesignModeWidget()
......@@ -275,9 +272,9 @@ void DesignModeWidget::setup()
QList<Core::INavigationWidgetFactory *> factories =
ExtensionSystem::PluginManager::getObjects<Core::INavigationWidgetFactory>();
QWidget *openDocumentsWidget = 0;
QWidget *projectsExplorer = 0;
QWidget *fileSystemExplorer = 0;
QWidget *openDocumentsWidget = nullptr;
QWidget *projectsExplorer = nullptr;
QWidget *fileSystemExplorer = nullptr;
foreach (Core::INavigationWidgetFactory *factory, factories) {
Core::NavigationView navigationView;
......@@ -414,16 +411,6 @@ void DesignModeWidget::setup()
show();
}
void DesignModeWidget::showQmlPuppetCrashedError()
{
QList<RewriterError> errorList;
RewriterError error(tr("Qt Quick emulation layer crashed"));
errorList.append(error);
disableWidgets();
showMessageBox(errorList);
}
void DesignModeWidget::toolBarOnGoBackClicked()
{
if (m_navigatorHistoryCounter > 0) {
......
......@@ -89,8 +89,6 @@ public slots:
void toggleRightSidebar();
private slots:
void showQmlPuppetCrashedError();
void toolBarOnGoBackClicked();
void toolBarOnGoForwardClicked();
......@@ -107,21 +105,21 @@ private: // functions
private: // variables
QSplitter *m_mainSplitter = nullptr;
DocumentWarningWidget *m_warningWidget = nullptr;
QPointer<DocumentWarningWidget> m_warningWidget;
QScopedPointer<Core::SideBar> m_leftSideBar;
QScopedPointer<Core::SideBar> m_rightSideBar;
QPointer<QWidget> m_topSideBar;
Core::EditorToolBar *m_toolBar;
CrumbleBar *m_crumbleBar;
bool m_isDisabled;
bool m_showSidebars;
bool m_isDisabled = false;
bool m_showSidebars = true;
InitializeStatus m_initStatus;
InitializeStatus m_initStatus = NotInitialized;
QStringList m_navigatorHistory;
int m_navigatorHistoryCounter;
bool m_keepNavigatorHistory;
int m_navigatorHistoryCounter = -1;
bool m_keepNavigatorHistory = false;
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