forked from qt-creator/qt-creator
DiffEditor: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews QSharedPointer impl is poor and it's going to be removed from Qt 7. Change-Id: I8364f20fddca43c22d47ba8df07a06a176950695 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -221,24 +221,24 @@ DiffEditor::DiffEditor()
|
|||||||
connect(m_viewSwitcherAction, &QAction::triggered, this, [this] { showDiffView(nextView()); });
|
connect(m_viewSwitcherAction, &QAction::triggered, this, [this] { showDiffView(nextView()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
|
void DiffEditor::setDocument(std::shared_ptr<DiffEditorDocument> doc)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_document.isNull(), return);
|
QTC_ASSERT(!m_document, return);
|
||||||
QTC_ASSERT(doc, return);
|
QTC_ASSERT(doc, return);
|
||||||
|
|
||||||
m_document = doc;
|
m_document = doc;
|
||||||
|
|
||||||
connect(m_document.data(), &DiffEditorDocument::documentChanged,
|
connect(m_document.get(), &DiffEditorDocument::documentChanged,
|
||||||
this, &DiffEditor::documentHasChanged);
|
this, &DiffEditor::documentHasChanged);
|
||||||
connect(m_document.data(), &DiffEditorDocument::descriptionChanged,
|
connect(m_document.get(), &DiffEditorDocument::descriptionChanged,
|
||||||
this, &DiffEditor::updateDescription);
|
this, &DiffEditor::updateDescription);
|
||||||
connect(m_document.data(), &DiffEditorDocument::aboutToReload,
|
connect(m_document.get(), &DiffEditorDocument::aboutToReload,
|
||||||
this, &DiffEditor::prepareForReload);
|
this, &DiffEditor::prepareForReload);
|
||||||
connect(m_document.data(), &DiffEditorDocument::reloadFinished,
|
connect(m_document.get(), &DiffEditorDocument::reloadFinished,
|
||||||
this, &DiffEditor::reloadHasFinished);
|
this, &DiffEditor::reloadHasFinished);
|
||||||
|
|
||||||
connect(m_reloadAction, &QAction::triggered, this, [this] { m_document->reload(); });
|
connect(m_reloadAction, &QAction::triggered, this, [this] { m_document->reload(); });
|
||||||
connect(m_document.data(), &DiffEditorDocument::temporaryStateChanged,
|
connect(m_document.get(), &DiffEditorDocument::temporaryStateChanged,
|
||||||
this, &DiffEditor::documentStateChanged);
|
this, &DiffEditor::documentStateChanged);
|
||||||
|
|
||||||
m_contextSpinBox->setValue(m_document->contextLineCount());
|
m_contextSpinBox->setValue(m_document->contextLineCount());
|
||||||
@@ -251,7 +251,7 @@ void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument> doc)
|
|||||||
DiffEditor::DiffEditor(DiffEditorDocument *doc) : DiffEditor()
|
DiffEditor::DiffEditor(DiffEditorDocument *doc) : DiffEditor()
|
||||||
{
|
{
|
||||||
GuardLocker guard(m_ignoreChanges);
|
GuardLocker guard(m_ignoreChanges);
|
||||||
setDocument(QSharedPointer<DiffEditorDocument>(doc));
|
setDocument(std::shared_ptr<DiffEditorDocument>(doc));
|
||||||
setupView(loadSettings());
|
setupView(loadSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ IEditor *DiffEditor::duplicate()
|
|||||||
|
|
||||||
IDocument *DiffEditor::document() const
|
IDocument *DiffEditor::document() const
|
||||||
{
|
{
|
||||||
return m_document.data();
|
return m_document.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DiffEditor::toolBar()
|
QWidget *DiffEditor::toolBar()
|
||||||
@@ -594,7 +594,7 @@ void DiffEditor::setupView(IDiffView *view)
|
|||||||
m_toggleSyncAction->setChecked(m_sync);
|
m_toggleSyncAction->setChecked(m_sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
view->setDocument(m_document.data());
|
view->setDocument(m_document.get());
|
||||||
view->setSync(m_sync);
|
view->setSync(m_sync);
|
||||||
view->setCurrentDiffFileIndex(m_currentDiffFileIndex);
|
view->setCurrentDiffFileIndex(m_currentDiffFileIndex);
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DiffEditor();
|
DiffEditor();
|
||||||
void setDocument(QSharedPointer<DiffEditorDocument> doc);
|
void setDocument(std::shared_ptr<DiffEditorDocument> doc);
|
||||||
|
|
||||||
void documentHasChanged();
|
void documentHasChanged();
|
||||||
void toggleDescription();
|
void toggleDescription();
|
||||||
@@ -69,7 +69,7 @@ private:
|
|||||||
IDiffView *nextView();
|
IDiffView *nextView();
|
||||||
void setupView(IDiffView *view);
|
void setupView(IDiffView *view);
|
||||||
|
|
||||||
QSharedPointer<DiffEditorDocument> m_document;
|
std::shared_ptr<DiffEditorDocument> m_document;
|
||||||
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
||||||
UnifiedView *m_unifiedView = nullptr;
|
UnifiedView *m_unifiedView = nullptr;
|
||||||
SideBySideView *m_sideBySideView = nullptr;
|
SideBySideView *m_sideBySideView = nullptr;
|
||||||
|
Reference in New Issue
Block a user