Commit a922accd authored by mae's avatar mae
Browse files

Fixed crash in combination with splits (some spurious

focus in events resulted in currentEditorView() being 0)
parent 9bdd3598
...@@ -1484,8 +1484,8 @@ void EditorManager::updateActions() ...@@ -1484,8 +1484,8 @@ void EditorManager::updateActions()
m_d->m_gotoNextDocHistoryAction->setEnabled(m_d->m_editorModel->rowCount() != 0); m_d->m_gotoNextDocHistoryAction->setEnabled(m_d->m_editorModel->rowCount() != 0);
m_d->m_gotoPreviousDocHistoryAction->setEnabled(m_d->m_editorModel->rowCount() != 0); m_d->m_gotoPreviousDocHistoryAction->setEnabled(m_d->m_editorModel->rowCount() != 0);
EditorView *view = currentEditorView(); EditorView *view = currentEditorView();
m_d->m_goBackAction->setEnabled(view->canGoBack()); m_d->m_goBackAction->setEnabled(view ? view->canGoBack() : false);
m_d->m_goForwardAction->setEnabled(view->canGoForward()); m_d->m_goForwardAction->setEnabled(view ? view->canGoForward() : false);
bool hasSplitter = m_d->m_splitter->isSplitter(); bool hasSplitter = m_d->m_splitter->isSplitter();
m_d->m_removeCurrentSplitAction->setEnabled(hasSplitter); m_d->m_removeCurrentSplitAction->setEnabled(hasSplitter);
......
...@@ -617,7 +617,6 @@ SplitterOrView::SplitterOrView(OpenEditorsModel *model) ...@@ -617,7 +617,6 @@ SplitterOrView::SplitterOrView(OpenEditorsModel *model)
m_view = new EditorView(model); m_view = new EditorView(model);
m_splitter = 0; m_splitter = 0;
m_layout->addWidget(m_view); m_layout->addWidget(m_view);
setFocusPolicy(Qt::ClickFocus);
} }
SplitterOrView::SplitterOrView(Core::IEditor *editor) SplitterOrView::SplitterOrView(Core::IEditor *editor)
...@@ -629,7 +628,6 @@ SplitterOrView::SplitterOrView(Core::IEditor *editor) ...@@ -629,7 +628,6 @@ SplitterOrView::SplitterOrView(Core::IEditor *editor)
m_view->addEditor(editor); m_view->addEditor(editor);
m_splitter = 0; m_splitter = 0;
m_layout->addWidget(m_view); m_layout->addWidget(m_view);
setFocusPolicy(Qt::ClickFocus);
} }
SplitterOrView::~SplitterOrView() SplitterOrView::~SplitterOrView()
...@@ -642,10 +640,11 @@ SplitterOrView::~SplitterOrView() ...@@ -642,10 +640,11 @@ SplitterOrView::~SplitterOrView()
m_splitter = 0; m_splitter = 0;
} }
void SplitterOrView::mousePressEvent(QMouseEvent *e)
void SplitterOrView::focusInEvent(QFocusEvent *)
{ {
if (e->button() != Qt::LeftButton)
return;
setFocus(Qt::MouseFocusReason);
CoreImpl::instance()->editorManager()->setCurrentView(this); CoreImpl::instance()->editorManager()->setCurrentView(this);
} }
...@@ -664,6 +663,7 @@ void SplitterOrView::paintEvent(QPaintEvent *) ...@@ -664,6 +663,7 @@ void SplitterOrView::paintEvent(QPaintEvent *)
const int r = 3; const int r = 3;
painter.drawRoundedRect(rect().adjusted(r, r, -r, -r), r * 2, r * 2); painter.drawRoundedRect(rect().adjusted(r, r, -r, -r), r * 2, r * 2);
#if 0
if (hasFocus()) { if (hasFocus()) {
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// With QMacStyle, we have to draw our own focus rect, since I didn't find // With QMacStyle, we have to draw our own focus rect, since I didn't find
...@@ -687,6 +687,7 @@ void SplitterOrView::paintEvent(QPaintEvent *) ...@@ -687,6 +687,7 @@ void SplitterOrView::paintEvent(QPaintEvent *)
} }
#endif #endif
} }
#endif
} }
SplitterOrView *SplitterOrView::findFirstView() SplitterOrView *SplitterOrView::findFirstView()
......
...@@ -199,8 +199,8 @@ public: ...@@ -199,8 +199,8 @@ public:
void unsplitAll(); void unsplitAll();
protected: protected:
void focusInEvent(QFocusEvent *);
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *e);
private: private:
......
Supports Markdown
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