Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some coding issues #18

Merged
merged 25 commits into from
Mar 1, 2017
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
31fbb6f
Use parented_ptr instead of raw pointer
jmigual Feb 14, 2017
b56d560
Merged branch jmigual-library-redesign into jmigual-library-redesign
jmigual Feb 14, 2017
a081b14
Remove usage of TrackCollection in Analysis View
jmigual Feb 14, 2017
e9a436e
Store QPointer instead of raw pointer in DlgAnalysis
jmigual Feb 14, 2017
ebc8d5a
Fix some includes and remove raw pointer
jmigual Feb 14, 2017
90cfe8a
Remove naked new pointer and use new TreeItem methods
jmigual Feb 14, 2017
ff89793
Remove more naked new pointers
jmigual Feb 14, 2017
c516ae6
Merged branch jmigual-library-redesign into jmigual-library-redesign
jmigual Feb 15, 2017
ef47826
Fix bug in browse feature when deleting a Quick Linkk
jmigual Feb 15, 2017
a558534
Add HistoryFeature actions in a parented_ptr
jmigual Feb 15, 2017
3eb165d
Add QPointer to getChildModel()
jmigual Feb 15, 2017
7cbe479
Fix maintenance feature pointer issues
jmigual Feb 15, 2017
6e46643
Fix naked pointers in MixxxLibraryFeature
jmigual Feb 15, 2017
95fdf79
Add parented_ptr in MixxxLibraryFeature
jmigual Feb 15, 2017
caa32b2
Add temporary parented_ptr fix
jmigual Feb 15, 2017
60372aa
Fix recording feature pointers
jmigual Feb 15, 2017
948ec4b
Use std::shared_ptr for LibraryPaneManager
jmigual Feb 15, 2017
709ecdb
Merge remote-tracking branch 'refs/remotes/daschuer/jmigual-library-r…
jmigual Feb 18, 2017
c5015af
Fix unnecessary const in parented_ptr
jmigual Feb 18, 2017
4c6565a
Use shared_ptr for features
jmigual Feb 24, 2017
5b9b3ec
Revert commit 948ec4b842d0482c967e354cd60ec31b51ac3baa
jmigual Feb 25, 2017
0b57f1b
Revert "Use shared_ptr for features"
jmigual Feb 24, 2017
7b6370d
Added nullptr checking to avoid segfaults
jmigual Feb 27, 2017
b165107
Add nullptr comparison operator to parented_ptr
jmigual Feb 27, 2017
0504ffa
Fix parent compilation issue with Qt4.8
jmigual Feb 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove more naked new pointers
  • Loading branch information
jmigual committed Feb 14, 2017
commit ff89793c9fb9db8a79ffffdc179cd9dcffb9893a
3 changes: 2 additions & 1 deletion src/library/features/baseplaylist/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
@@ -118,7 +118,8 @@ QPointer<PlaylistTableModel> BasePlaylistFeature::getPlaylistTableModel(int pane
}
auto it = m_playlistTableModel.find(paneId);
if (it == m_playlistTableModel.end() || it->isNull()) {
it = m_playlistTableModel.insert(paneId, constructTableModel());
auto pTableModel = constructTableModel();
it = m_playlistTableModel.insert(paneId, pTableModel.toWeakRef());
}
return *it;
}
2 changes: 1 addition & 1 deletion src/library/features/baseplaylist/baseplaylistfeature.h
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ class BasePlaylistFeature : public LibraryFeature {
QString getValidPlaylistName() const;

QPointer<PlaylistTableModel> getPlaylistTableModel(int paneId = -1);
virtual PlaylistTableModel* constructTableModel() = 0;
virtual parented_ptr<PlaylistTableModel> constructTableModel() = 0;

virtual QSet<int> playlistIdsFromIndex(const QModelIndex& index) const;
int playlistIdFromIndex(const QModelIndex& index) const;
30 changes: 16 additions & 14 deletions src/library/features/browse/browsefeature.cpp
Original file line number Diff line number Diff line change
@@ -28,8 +28,7 @@ BrowseFeature::BrowseFeature(UserSettingsPointer pConfig,
: LibraryFeature(pConfig, pLibrary, pTrackCollection, parent),
m_browseModel(this, pTrackCollection, pRecordingManager),
m_proxyModel(&m_browseModel),
m_pTrackCollection(pTrackCollection),
m_pLastRightClickedItem(NULL) {
m_pTrackCollection(pTrackCollection) {
connect(this, SIGNAL(requestAddDir(QString)),
parent, SLOT(slotRequestAddDir(QString)));

@@ -54,7 +53,8 @@ BrowseFeature::BrowseFeature(UserSettingsPointer pConfig,
// The invisible root item of the child model
auto pRootItem = std::make_unique<TreeItem>(this);

m_pQuickLinkItem = pRootItem->appendChild(tr("Quick Links"), QUICK_LINK_NODE);
m_pQuickLinkItem = parented_ptr<TreeItem>(
pRootItem->appendChild(tr("Quick Links"), QUICK_LINK_NODE));

// Create the 'devices' shortcut
#if defined(__WINDOWS__)
@@ -132,11 +132,11 @@ QString BrowseFeature::getSettingsName() const {
}

void BrowseFeature::slotAddQuickLink() {
if (!m_pLastRightClickedItem) {
if (!m_lastRightClickedIndex.isValid()) {
return;
}

QVariant vpath = m_pLastRightClickedItem->getData();
QVariant vpath = m_lastRightClickedIndex.data(AbstractRole::RoleData);
QString spath = vpath.toString();
QString name = extractNameFromPath(spath);
m_pQuickLinkItem->appendChild(name, vpath);
@@ -145,10 +145,10 @@ void BrowseFeature::slotAddQuickLink() {
}

void BrowseFeature::slotAddToLibrary() {
if (!m_pLastRightClickedItem) {
if (!m_lastRightClickedIndex.isValid()) {
return;
}
QString spath = m_pLastRightClickedItem->getData().toString();
QString spath = m_lastRightClickedIndex.data(AbstractRole::RoleData).toString();
emit(requestAddDir(spath));

QMessageBox msgBox;
@@ -178,11 +178,11 @@ void BrowseFeature::slotLibraryScanFinished() {
}

void BrowseFeature::slotRemoveQuickLink() {
if (!m_pLastRightClickedItem) {
if (!m_lastRightClickedIndex.isValid()) {
return;
}

QString spath = m_pLastRightClickedItem->getData().toString();
QString spath = m_lastRightClickedIndex.data(AbstractRole::RoleData).toString();
int index = m_quickLinkList.indexOf(spath);

if (index == -1) {
@@ -260,14 +260,13 @@ void BrowseFeature::activateChild(const QModelIndex& index) {
}

void BrowseFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index) {
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
m_pLastRightClickedItem = item;
TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
m_lastRightClickedIndex = index;

if (!item) {
if (!index.isValid())
return;
}

QString path = item->getData().toString();
QString path = index.data(AbstractRole::RoleData).toString();

if (path == QUICK_LINK_NODE || path == DEVICE_NODE) {
return;
@@ -296,6 +295,9 @@ void BrowseFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index
// This is called whenever you double click or use the triangle symbol to expand
// the subtree. The method will read the subfolders.
void BrowseFeature::onLazyChildExpandation(const QModelIndex& index) {
if (!index.isValid())
return;

TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
if (!item) {
return;
4 changes: 2 additions & 2 deletions src/library/features/browse/browsefeature.h
Original file line number Diff line number Diff line change
@@ -77,8 +77,8 @@ class BrowseFeature : public LibraryFeature {
QAction* m_pAddQuickLinkAction;
QAction* m_pRemoveQuickLinkAction;
QAction* m_pAddtoLibraryAction;
TreeItem* m_pLastRightClickedItem;
TreeItem* m_pQuickLinkItem;
QPersistentModelIndex m_lastRightClickedIndex;
parented_ptr<TreeItem> m_pQuickLinkItem;
QStringList m_quickLinkList;
QPersistentModelIndex m_lastClickedChild;

6 changes: 3 additions & 3 deletions src/library/features/history/historyfeature.cpp
Original file line number Diff line number Diff line change
@@ -152,9 +152,9 @@ QModelIndex HistoryFeature::constructChildModel(int selected_id) {
return index;
}

PlaylistTableModel* HistoryFeature::constructTableModel() {
return new PlaylistTableModel(this, m_pTrackCollection,
"mixxx.db.model.setlog", true);
parented_ptr<PlaylistTableModel> HistoryFeature::constructTableModel() {
return make_parented<PlaylistTableModel>(this, m_pTrackCollection,
"mixxx.db.model.setlog", true);
}

QSet<int> HistoryFeature::playlistIdsFromIndex(const QModelIndex& index) const {
2 changes: 1 addition & 1 deletion src/library/features/history/historyfeature.h
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class HistoryFeature : public BasePlaylistFeature {
const TreeItemModel* getConstChildModel() const override;
void buildPlaylistList() override;
QModelIndex constructChildModel(int selected_id);
PlaylistTableModel* constructTableModel() override;
parented_ptr<PlaylistTableModel> constructTableModel() override;
QSet<int> playlistIdsFromIndex(const QModelIndex &index) const override;
QModelIndex indexFromPlaylistId(int playlistId) const override;

5 changes: 3 additions & 2 deletions src/library/features/playlist/playlistfeature.cpp
Original file line number Diff line number Diff line change
@@ -207,8 +207,9 @@ void PlaylistFeature::decorateChild(TreeItem* item, int playlist_id) {
}
}

PlaylistTableModel* PlaylistFeature::constructTableModel() {
return new PlaylistTableModel(this, m_pTrackCollection, "mixxx.db.model.playlist");
parented_ptr<PlaylistTableModel> PlaylistFeature::constructTableModel() {
return make_parented<PlaylistTableModel>(this, m_pTrackCollection,
"mixxx.db.model.playlist");
}

void PlaylistFeature::slotPlaylistTableChanged(int playlistId) {
2 changes: 1 addition & 1 deletion src/library/features/playlist/playlistfeature.h
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ class PlaylistFeature : public BasePlaylistFeature {
const TreeItemModel* getConstChildModel() const override;
void buildPlaylistList();
void decorateChild(TreeItem *pChild, int playlist_id);
PlaylistTableModel* constructTableModel();
parented_ptr<PlaylistTableModel> constructTableModel();

private:
QString getRootViewHtml() const;