Fixed a bug that could lead to an infinite loop when trying to install an update from auto-update and the WMA decoder component was not installed yet.

This commit is contained in:
LoRd_MuldeR 2011-02-18 00:53:36 +01:00
parent 9b31e95690
commit 5902f1822d
7 changed files with 74 additions and 31 deletions

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 317
#define VER_LAMEXP_BUILD 319
#define VER_LAMEXP_SUFFIX RC-2
/*

View File

@ -439,11 +439,13 @@ void MainWindow::addFiles(const QStringList &files)
/*
* Download and install WMA Decoder component
*/
void MainWindow::installWMADecoder(void)
bool MainWindow::installWMADecoder(void)
{
static const char *download_url = "http://www.nch.com.au/components/wmawav.exe";
static const char *download_hash = "52a3b0e6690faf3f830c336d3c0eadfb7a4e9bc6";
bool bResult = false;
QString binaryWGet = lamexp_lookup_tool("wget.exe");
QString binaryElevator = lamexp_lookup_tool("elevator.exe");
@ -473,7 +475,7 @@ void MainWindow::installWMADecoder(void)
{
continue;
}
return;
break;
}
QFile setupFileContent(setupFile);
@ -494,7 +496,7 @@ void MainWindow::installWMADecoder(void)
{
continue;
}
return;
break;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
@ -505,10 +507,32 @@ void MainWindow::installWMADecoder(void)
if(QMessageBox::information(this, tr("WMA Decoder"), tr("The WMA File Decoder has been installed. Please restart LameXP now!"), tr("Quit LameXP"), tr("Postpone")) == 0)
{
QApplication::quit();
bResult = true;
}
break;
}
return bResult;
}
/*
* Check for updates
*/
bool MainWindow::checkForUpdates(void)
{
bool bReadyToInstall = false;
UpdateDialog *updateDialog = new UpdateDialog(m_settings, this);
updateDialog->exec();
if(updateDialog->getSuccess())
{
m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate));
bReadyToInstall = updateDialog->updateReadyToInstall();
}
LAMEXP_DELETE(updateDialog);
return bReadyToInstall;
}
////////////////////////////////////////////////////////////
@ -739,7 +763,7 @@ void MainWindow::windowShown(void)
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
if(QMessageBox::warning(this, tr("LameXP - Expired"), QString("<nobr>%1<br>%2</nobr>").arg(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate)), tr("LameXP is free software and release versions won't expire.")), tr("Check for Updates"), tr("Exit Program")) == 0)
{
checkUpdatesActionActivated();
checkForUpdates();
}
QApplication::quit();
return;
@ -752,7 +776,11 @@ void MainWindow::windowShown(void)
qWarning("Binary is more than a year old, time to update!");
if(QMessageBox::warning(this, tr("Urgent Update"), QString("<nobr>%1</nobr>").arg(tr("Your version of LameXP is more than a year old. Time for an update!")), tr("Check for Updates"), tr("Exit Program")) == 0)
{
checkUpdatesActionActivated();
if(checkForUpdates())
{
QApplication::quit();
return;
}
}
else
{
@ -767,7 +795,11 @@ void MainWindow::windowShown(void)
{
if(QMessageBox::information(this, tr("Update Reminder"), QString("<nobr>%1</nobr>").arg(lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0)
{
checkUpdatesActionActivated();
if(checkForUpdates())
{
QApplication::quit();
return;
}
}
}
}
@ -814,7 +846,11 @@ void MainWindow::windowShown(void)
messageText += QString("%1</nobr>").arg(tr("Do you want to download and install the WMA File Decoder component now?"));
if(QMessageBox::information(this, tr("WMA Decoder Missing"), messageText, tr("Download && Install"), tr("Postpone")) == 0)
{
installWMADecoder();
if(installWMADecoder())
{
QApplication::quit();
return;
}
}
}
}
@ -1453,13 +1489,10 @@ void MainWindow::checkUpdatesActionActivated(void)
TEMP_HIDE_DROPBOX
(
UpdateDialog *updateDialog = new UpdateDialog(m_settings, this);
updateDialog->exec();
if(updateDialog->getSuccess())
if(checkForUpdates())
{
m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate));
QApplication::quit();
}
LAMEXP_DELETE(updateDialog);
)
}
@ -2185,7 +2218,11 @@ void MainWindow::installWMADecoderActionTriggered(bool checked)
{
if(QMessageBox::question(this, tr("Install WMA Decoder"), tr("Do you want to download and install the WMA File Decoder component now?"), tr("Download && Install"), tr("Cancel")) == 0)
{
installWMADecoder();
if(installWMADecoder())
{
QApplication::quit();
return;
}
}
}

View File

@ -124,7 +124,8 @@ protected:
private:
void addFiles(const QStringList &files);
void installWMADecoder(void);
bool installWMADecoder(void);
bool checkForUpdates(void);
bool m_accepted;
bool m_firstTimeShown;

View File

@ -111,7 +111,8 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
m_updateInfo(NULL),
m_settings(settings),
m_logFile(new QStringList()),
m_success(false)
m_success(false),
m_updateReadyToInstall(false)
{
if(m_binaryWGet.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryUpdater.isEmpty() || m_binaryKeys.isEmpty())
{
@ -565,7 +566,7 @@ void UpdateDialog::applyUpdate(void)
if(process.exitCode() == 0)
{
statusLabel->setText("Update ready to install. Applicaion will quit...");
QApplication::quit();
m_updateReadyToInstall = true;
accept();
}
else

View File

@ -37,6 +37,7 @@ public:
~UpdateDialog(void);
bool getSuccess(void) { return m_success; }
bool updateReadyToInstall(void) { return m_updateReadyToInstall; }
private slots:
void updateInit(void);
@ -66,4 +67,5 @@ private:
const QString m_binaryKeys;
bool m_success;
bool m_updateReadyToInstall;
};

View File

@ -443,19 +443,26 @@ lamexp_cpu_t lamexp_detect_cpu_features(void)
/*
* Check for debugger
*/
void WINAPI debugThreadProc(__in LPVOID lpParameter)
#if !defined(_DEBUG) || defined(NDEBUG)
void WINAPI lamexp_debug_thread_proc(__in LPVOID lpParameter)
{
BOOL remoteDebuggerPresent = FALSE;
//CheckRemoteDebuggerPresent(GetCurrentProcess, &remoteDebuggerPresent);
while(!IsDebuggerPresent() && !remoteDebuggerPresent)
while(!IsDebuggerPresent())
{
Sleep(333);
//CheckRemoteDebuggerPresent(GetCurrentProcess, &remoteDebuggerPresent);
}
TerminateProcess(GetCurrentProcess(), -1);
}
HANDLE lamexp_debug_thread_init(void)
{
if(IsDebuggerPresent())
{
FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!");
TerminateProcess(GetCurrentProcess(), -1);
}
return CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(&lamexp_debug_thread_proc), NULL, NULL, NULL);
}
static const HANDLE g_debug_thread = lamexp_debug_thread_init();
#endif
/*
* Check for compatibility mode

View File

@ -130,12 +130,7 @@ SIZE_T lamexp_dbg_private_bytes(void);
qWarning("---------------------------------------------------------\n");
#else
#define LAMEXP_DEBUG 0
#define LAMEXP_CHECK_DEBUG_BUILD \
if(IsDebuggerPresent()) { \
FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!"); \
TerminateProcess(GetCurrentProcess, -1); } \
CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(&debugThreadProc), NULL, NULL, NULL);
void WINAPI debugThreadProc(__in LPVOID lpParameter);
#define LAMEXP_CHECK_DEBUG_BUILD
#endif
//Memory check