From 3c98bd5de4d1573f419522f42011c4bac9117df4 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Thu, 30 Jul 2009 20:31:52 +0000 Subject: [PATCH] Fixed the crash bug in the iTunesPlugin. --- Plugins/PluginiTunes/iTunesPlugin.cpp | 20 ++++++++++++++++---- revision-number.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Plugins/PluginiTunes/iTunesPlugin.cpp b/Plugins/PluginiTunes/iTunesPlugin.cpp index 58b477c2..2459aab3 100644 --- a/Plugins/PluginiTunes/iTunesPlugin.cpp +++ b/Plugins/PluginiTunes/iTunesPlugin.cpp @@ -294,7 +294,8 @@ static bool updateCurrentTrack() if (0 == lastClock || currentClock - lastClock > CLOCKS_PER_SEC) { wsprintf(CurrentTrackArtworkPath, L"%s%s", BaseDir, DefaultTrackArtworkPath); - CurrentTrack.Release(); + if (CurrentTrack != NULL) + CurrentTrack.Release(); if (FAILED(iTunes->get_CurrentTrack(&CurrentTrack)) || !CurrentTrack) return false; @@ -362,11 +363,22 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) CoInitialized = true; } - if (CoInitialized && !InstanceCreated && ::FindWindow(L"iTunes", L"iTunes") && - SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER))) + if (CoInitialized && !InstanceCreated /*&& ::FindWindow(L"iTunes", L"iTunes") */) // rainy: Removed the FindWindow since it fails in 64-bit OS { - InstanceCreated = true; + if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER))) + { + InstanceCreated = true; + LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesApp initialized successfully."); + } + else + { + LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to create the iTunesApp instance."); + } } + else + { + LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to find the iTunes window."); + } const wchar_t* type = ReadConfigString(section, L"Command", L""); for(int i = 0; i < COMMAND_COUNT; i++) diff --git a/revision-number.h b/revision-number.h index 535443e4..be266459 100644 --- a/revision-number.h +++ b/revision-number.h @@ -1,2 +1,2 @@ #pragma once -const int revision_number = 117; \ No newline at end of file +const int revision_number = 119; \ No newline at end of file