mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-02 19:14:05 +00:00
clean: deprecations that won't break Qt5 compatibility
This commit is contained in:
parent
be22cb22b6
commit
48fc8fceff
|
@ -65,9 +65,9 @@ void AudioPlayerFactory::reset()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QScopedPointer< ExternalAudioPlayer > externalPlayer( new ExternalAudioPlayer );
|
std::unique_ptr< ExternalAudioPlayer > externalPlayer( new ExternalAudioPlayer );
|
||||||
setAudioPlaybackProgram( *externalPlayer );
|
setAudioPlaybackProgram( *externalPlayer );
|
||||||
playerPtr.reset( externalPlayer.take() );
|
playerPtr.reset( externalPlayer.release() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioPlayerFactory::setAudioPlaybackProgram( ExternalAudioPlayer & externalPlayer )
|
void AudioPlayerFactory::setAudioPlaybackProgram( ExternalAudioPlayer & externalPlayer )
|
||||||
|
|
|
@ -41,7 +41,7 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg ):
|
||||||
// anyone?
|
// anyone?
|
||||||
QItemEditorCreatorBase * programTypeEditorCreator = new QStandardItemEditorCreator< ProgramTypeEditor >();
|
QItemEditorCreatorBase * programTypeEditorCreator = new QStandardItemEditorCreator< ProgramTypeEditor >();
|
||||||
|
|
||||||
itemEditorFactory->registerEditor( QVariant::Int, programTypeEditorCreator );
|
itemEditorFactory->registerEditor( QMetaType::Int, programTypeEditorCreator );
|
||||||
|
|
||||||
itemDelegate->setItemEditorFactory( itemEditorFactory.get() );
|
itemDelegate->setItemEditorFactory( itemEditorFactory.get() );
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ ExternalAudioPlayer::~ExternalAudioPlayer()
|
||||||
|
|
||||||
// Set viewer to null first and foremost to make sure that onViewerDestroyed()
|
// Set viewer to null first and foremost to make sure that onViewerDestroyed()
|
||||||
// doesn't attempt to start viewer or mess the smart pointer up.
|
// doesn't attempt to start viewer or mess the smart pointer up.
|
||||||
stopAndDestroySynchronously( viewer.take() );
|
stopAndDestroySynchronously( viewer.release() );
|
||||||
|
|
||||||
stopAndDestroySynchronously( exitingViewer );
|
stopAndDestroySynchronously( exitingViewer );
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ void ExternalAudioPlayer::stop()
|
||||||
// 1) the process gets a chance to clean up and save its state;
|
// 1) the process gets a chance to clean up and save its state;
|
||||||
// 2) there is no event loop blocking and consequently no (short) UI freeze
|
// 2) there is no event loop blocking and consequently no (short) UI freeze
|
||||||
// while synchronously waiting for the external process to exit.
|
// while synchronously waiting for the external process to exit.
|
||||||
exitingViewer = viewer.take();
|
exitingViewer = viewer.release();
|
||||||
}
|
}
|
||||||
else // viewer is either not started or already stopped -> simply destroy it.
|
else // viewer is either not started or already stopped -> simply destroy it.
|
||||||
viewer.reset();
|
viewer.reset();
|
||||||
|
@ -72,14 +72,14 @@ void ExternalAudioPlayer::onViewerDestroyed( QObject * destroyedViewer )
|
||||||
emit error( errorMessage );
|
emit error( errorMessage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( viewer.data() == destroyedViewer )
|
else if ( viewer.get() == destroyedViewer )
|
||||||
viewer.take(); // viewer finished and died -> release ownership.
|
viewer.reset(nullptr); // viewer finished and died -> reset
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ExternalAudioPlayer::startViewer()
|
QString ExternalAudioPlayer::startViewer()
|
||||||
{
|
{
|
||||||
Q_ASSERT( !exitingViewer && viewer );
|
Q_ASSERT( !exitingViewer && viewer );
|
||||||
connect( viewer.data(), &QObject::destroyed, this, &ExternalAudioPlayer::onViewerDestroyed );
|
connect( viewer.get(), &QObject::destroyed, this, &ExternalAudioPlayer::onViewerDestroyed );
|
||||||
try {
|
try {
|
||||||
viewer->start();
|
viewer->start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
#ifndef EXTERNALAUDIOPLAYER_HH_INCLUDED
|
#ifndef EXTERNALAUDIOPLAYER_HH_INCLUDED
|
||||||
#define EXTERNALAUDIOPLAYER_HH_INCLUDED
|
#define EXTERNALAUDIOPLAYER_HH_INCLUDED
|
||||||
|
|
||||||
#include <QScopedPointer>
|
|
||||||
#include <QString>
|
|
||||||
#include "audioplayerinterface.hh"
|
#include "audioplayerinterface.hh"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class ExternalViewer;
|
class ExternalViewer;
|
||||||
|
|
||||||
|
@ -34,16 +33,16 @@ private:
|
||||||
///< the current viewer (if any) is not started yet
|
///< the current viewer (if any) is not started yet
|
||||||
///< and waits for exitingViewer to be destroyed first.
|
///< and waits for exitingViewer to be destroyed first.
|
||||||
|
|
||||||
struct ScopedPointerDeleteLater
|
struct QObjectDeleteLater
|
||||||
{
|
{
|
||||||
static void cleanup( QObject * p )
|
void operator()( QObject * p )
|
||||||
{
|
{
|
||||||
if ( p )
|
if ( p )
|
||||||
p->deleteLater();
|
p->deleteLater();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// deleteLater() is safer because viewer actively participates in the QEventLoop.
|
// deleteLater() is safer because viewer actively participates in the QEventLoop.
|
||||||
QScopedPointer< ExternalViewer, ScopedPointerDeleteLater > viewer;
|
std::unique_ptr< ExternalViewer, QObjectDeleteLater > viewer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXTERNALAUDIOPLAYER_HH_INCLUDED
|
#endif // EXTERNALAUDIOPLAYER_HH_INCLUDED
|
||||||
|
|
|
@ -150,7 +150,7 @@ void HeadwordListModel::fetchMore( const QModelIndex & parent )
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet< QString > filtered;
|
QSet< QString > filtered;
|
||||||
for ( const auto & word : qAsConst( headword ) ) {
|
for ( const auto & word : std::as_const( headword ) ) {
|
||||||
if ( !containWord( word ) )
|
if ( !containWord( word ) )
|
||||||
filtered.insert( word );
|
filtered.insert( word );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue