*Fix device lister shutdown on mac

*Remove a bunch of debug
*Fix a windows translation
This commit is contained in:
John Maguire 2010-08-23 10:26:00 +00:00
parent 7821a48cb7
commit 2e03a2f093
9 changed files with 26 additions and 12 deletions

View File

@ -586,6 +586,8 @@ list(APPEND OTHER_SOURCES
devices/mtploader.h
devices/wmdmlister.cpp
devices/wmdmlister.h
devices/wmdmloader.h
devices/wmdmloader.cpp
ui/macsystemtrayicon.h
ui/macsystemtrayicon.mm
widgets/osd_mac.mm

View File

@ -10,6 +10,8 @@ AnalyzerBase::AnalyzerBase(QWidget* parent)
void AnalyzerBase::set_engine(Engine::Base* engine) {
disconnect(engine_);
engine_ = engine;
connect(engine_, SIGNAL(SpectrumAvailable(const QVector<float>&)),
SLOT(SpectrumAvailable(const QVector<float>&)));
if (engine_) {
connect(engine_, SIGNAL(SpectrumAvailable(const QVector<float>&)),
SLOT(SpectrumAvailable(const QVector<float>&)));
}
}

View File

@ -12,7 +12,6 @@ GLBlockAnalyzer::GLBlockAnalyzer(QWidget* parent)
: AnalyzerBase(parent),
rectangles_size_(0),
shader_(this) {
qDebug() << Q_FUNC_INFO;
}
void GLBlockAnalyzer::SpectrumAvailable(const QVector<float>& spectrum) {
@ -21,7 +20,6 @@ void GLBlockAnalyzer::SpectrumAvailable(const QVector<float>& spectrum) {
}
void GLBlockAnalyzer::initializeGL() {
qDebug() << Q_FUNC_INFO;
QColor background_color = QApplication::palette().color(QPalette::Window);
qglClearColor(background_color);
@ -38,7 +36,6 @@ void GLBlockAnalyzer::initializeGL() {
}
void GLBlockAnalyzer::resizeGL(int w, int h) {
qDebug() << Q_FUNC_INFO;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);

View File

@ -32,7 +32,6 @@ DeviceLister::DeviceLister()
}
DeviceLister::~DeviceLister() {
qDebug() << __PRETTY_FUNCTION__;
if (thread_) {
thread_->quit();
thread_->wait(1000);

View File

@ -204,9 +204,7 @@ DeviceManager::DeviceManager(BackgroundThread<Database>* database,
DeviceManager::~DeviceManager() {
foreach (DeviceLister* lister, listers_) {
// Let the lister close itself down
metaObject()->invokeMethod(lister, "ShutDown", Qt::BlockingQueuedConnection);
lister->ShutDown();
delete lister;
}

View File

@ -28,6 +28,9 @@ class MacDeviceLister : public DeviceLister {
virtual void UnmountDevice(const QString &id);
virtual void UpdateDeviceFreeSpace(const QString& id);
public slots:
virtual void ShutDown();
private:
virtual void Init();
@ -38,6 +41,7 @@ class MacDeviceLister : public DeviceLister {
DADiskRef disk, DADissenterRef dissenter, void* context);
DASessionRef loop_session_;
CFRunLoopRef run_loop_;
QMap<QString, QString> current_devices_;
};

View File

@ -40,18 +40,22 @@ MacDeviceLister::~MacDeviceLister() {
void MacDeviceLister::Init() {
[[NSAutoreleasePool alloc] init];
CFRunLoopRef run_loop = CFRunLoopGetCurrent();
run_loop_ = CFRunLoopGetCurrent();
loop_session_ = DASessionCreate(kCFAllocatorDefault);
DARegisterDiskAppearedCallback(
loop_session_, kDADiskDescriptionMatchVolumeMountable, &DiskAddedCallback, reinterpret_cast<void*>(this));
DARegisterDiskDisappearedCallback(
loop_session_, NULL, &DiskRemovedCallback, reinterpret_cast<void*>(this));
DASessionScheduleWithRunLoop(loop_session_, run_loop, kCFRunLoopDefaultMode);
DASessionScheduleWithRunLoop(loop_session_, run_loop_, kCFRunLoopDefaultMode);
CFRunLoopRun();
}
void MacDeviceLister::ShutDown() {
CFRunLoopStop(run_loop_);
}
// IOKit helpers.
namespace {

View File

@ -103,7 +103,7 @@ void WmdmLister::Init() {
}
}
void WmdmLister::ShutDown() {
void WmdmLister::ReallyShutdown() {
// Unregister for notifications
IConnectionPointContainer* cp_container;
thread_->manager()->QueryInterface(IID_IConnectionPointContainer, (void**)&cp_container);
@ -117,6 +117,11 @@ void WmdmLister::ShutDown() {
thread_.reset();
}
void WmdmLister::ShutDown() {
// COM shutdown must be done in the original thread.
metaObject()->invokeMethod(this, "ReallyShutdown", Qt::BlockingQueuedConnection);
}
template <typename F>
qint64 GetSpaceValue(F f) {
DWORD low, high;

View File

@ -66,6 +66,9 @@ public slots:
virtual void UpdateDeviceFreeSpace(const QString& id);
virtual void ShutDown();
private slots:
virtual void ReallyShutdown();
private:
struct DeviceInfo {
DeviceInfo() : device_(NULL), storage_(NULL), is_suitable_(false),