Refactored finalization code, so each "Global..." file can have its own finalization function.
This commit is contained in:
parent
fa3b373e99
commit
ff30f71c13
@ -327,7 +327,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
|
|||||||
<ClCompile Include="src\Filter_Resample.cpp" />
|
<ClCompile Include="src\Filter_Resample.cpp" />
|
||||||
<ClCompile Include="src\Filter_ToneAdjust.cpp" />
|
<ClCompile Include="src\Filter_ToneAdjust.cpp" />
|
||||||
<ClCompile Include="src\Genres.cpp" />
|
<ClCompile Include="src\Genres.cpp" />
|
||||||
<ClCompile Include="src\Global_EntryPoint.cpp" />
|
<ClCompile Include="src\Global_Zero.cpp" />
|
||||||
<ClCompile Include="src\Global_IPC.cpp" />
|
<ClCompile Include="src\Global_IPC.cpp" />
|
||||||
<ClCompile Include="src\Global_Utils.cpp" />
|
<ClCompile Include="src\Global_Utils.cpp" />
|
||||||
<ClCompile Include="src\Global_Version.cpp" />
|
<ClCompile Include="src\Global_Version.cpp" />
|
||||||
|
@ -406,9 +406,6 @@
|
|||||||
<ClCompile Include="src\Global_IPC.cpp">
|
<ClCompile Include="src\Global_IPC.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Global_EntryPoint.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Global_Version.cpp">
|
<ClCompile Include="src\Global_Version.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -421,6 +418,9 @@
|
|||||||
<ClCompile Include="tmp\MOC_Thread_CheckUpdate.cpp">
|
<ClCompile Include="tmp\MOC_Thread_CheckUpdate.cpp">
|
||||||
<Filter>Generated Files\MOC</Filter>
|
<Filter>Generated Files\MOC</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Global_Zero.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\Config.h">
|
<ClInclude Include="src\Config.h">
|
||||||
|
11
src/Global.h
11
src/Global.h
@ -135,6 +135,9 @@ typedef enum
|
|||||||
}
|
}
|
||||||
lamexp_syscolor_t;
|
lamexp_syscolor_t;
|
||||||
|
|
||||||
|
//Icon type
|
||||||
|
class lamexp_icon_t;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// GLOBAL FUNCTIONS
|
// GLOBAL FUNCTIONS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -156,8 +159,6 @@ bool lamexp_check_sysmenu_msg(void *message, const unsigned int identifier);
|
|||||||
bool lamexp_check_tool(const QString &toolName);
|
bool lamexp_check_tool(const QString &toolName);
|
||||||
const QString lamexp_clean_filename(const QString &str);
|
const QString lamexp_clean_filename(const QString &str);
|
||||||
const QString lamexp_clean_filepath(const QString &str);
|
const QString lamexp_clean_filepath(const QString &str);
|
||||||
void lamexp_clean_all_tools(void);
|
|
||||||
void lamexp_clean_all_translations(void);
|
|
||||||
bool lamexp_clean_folder(const QString &folderPath);
|
bool lamexp_clean_folder(const QString &folderPath);
|
||||||
QDate lamexp_current_date_safe(void);
|
QDate lamexp_current_date_safe(void);
|
||||||
unsigned __int64 lamexp_current_file_time(void);
|
unsigned __int64 lamexp_current_file_time(void);
|
||||||
@ -171,6 +172,7 @@ bool lamexp_exec_shell(const QWidget *win, const QString &url, const QString &pa
|
|||||||
void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
|
void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
|
||||||
void lamexp_finalization(void);
|
void lamexp_finalization(void);
|
||||||
unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
|
unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL);
|
||||||
|
void lamexp_free_window_icon(lamexp_icon_t *icon);
|
||||||
const lamexp_os_version_t &lamexp_get_os_version(void);
|
const lamexp_os_version_t &lamexp_get_os_version(void);
|
||||||
void lamexp_init_console(const QStringList &argv);
|
void lamexp_init_console(const QStringList &argv);
|
||||||
void lamexp_init_error_handlers(void);
|
void lamexp_init_error_handlers(void);
|
||||||
@ -180,7 +182,6 @@ bool lamexp_init_qt(int argc, char* argv[]);
|
|||||||
bool lamexp_install_translator(const QString &language);
|
bool lamexp_install_translator(const QString &language);
|
||||||
bool lamexp_install_translator_from_file(const QString &qmFile);
|
bool lamexp_install_translator_from_file(const QString &qmFile);
|
||||||
void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
|
void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
|
||||||
void lamexp_ipc_exit(void);
|
|
||||||
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
||||||
void lamexp_ipc_send(unsigned int command, const char* message);
|
void lamexp_ipc_send(unsigned int command, const char* message);
|
||||||
bool lamexp_is_hibernation_supported(void);
|
bool lamexp_is_hibernation_supported(void);
|
||||||
@ -204,15 +205,15 @@ QString lamexp_rand_str(const bool bLong = false);
|
|||||||
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
|
void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
|
||||||
bool lamexp_remove_file(const QString &filename);
|
bool lamexp_remove_file(const QString &filename);
|
||||||
void lamexp_seed_rand(void);
|
void lamexp_seed_rand(void);
|
||||||
bool lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
|
lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon);
|
||||||
bool lamexp_sheet_of_glass(QWidget *window);
|
bool lamexp_sheet_of_glass(QWidget *window);
|
||||||
bool lamexp_sheet_of_glass_update(QWidget *window);
|
bool lamexp_sheet_of_glass_update(QWidget *window);
|
||||||
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
|
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
|
||||||
void lamexp_sleep(const unsigned int delay);
|
void lamexp_sleep(const unsigned int delay);
|
||||||
QColor lamexp_system_color(const int color_id);
|
QColor lamexp_system_color(const int color_id);
|
||||||
|
int lamexp_system_message(const wchar_t *text, int beepType);
|
||||||
const char *lamexp_support_url(void);
|
const char *lamexp_support_url(void);
|
||||||
const QString &lamexp_temp_folder2(void);
|
const QString &lamexp_temp_folder2(void);
|
||||||
void lamexp_temp_folder_clear(void);
|
|
||||||
bool lamexp_themes_enabled(void);
|
bool lamexp_themes_enabled(void);
|
||||||
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
|
unsigned int lamexp_tool_version(const QString &toolName, QString *tag = NULL);
|
||||||
unsigned int lamexp_toolver_coreaudio(void);
|
unsigned int lamexp_toolver_coreaudio(void);
|
||||||
|
@ -255,19 +255,6 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Exit and clean-up IPC
|
|
||||||
*/
|
|
||||||
void lamexp_ipc_exit(void)
|
|
||||||
{
|
|
||||||
if(g_lamexp_ipc_ptr.sharedmem) g_lamexp_ipc_ptr.sharedmem->detach();
|
|
||||||
LAMEXP_DELETE(g_lamexp_ipc_ptr.sharedmem);
|
|
||||||
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read);
|
|
||||||
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write);
|
|
||||||
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read_mutex);
|
|
||||||
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// INITIALIZATION
|
// INITIALIZATION
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -276,3 +263,21 @@ extern "C" void _lamexp_global_init_ipcom(void)
|
|||||||
{
|
{
|
||||||
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
|
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FINALIZATION
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" void _lamexp_global_free_ipcom(void)
|
||||||
|
{
|
||||||
|
if(g_lamexp_ipc_ptr.sharedmem)
|
||||||
|
{
|
||||||
|
g_lamexp_ipc_ptr.sharedmem->detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
LAMEXP_DELETE(g_lamexp_ipc_ptr.sharedmem);
|
||||||
|
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read);
|
||||||
|
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write);
|
||||||
|
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_read_mutex);
|
||||||
|
LAMEXP_DELETE(g_lamexp_ipc_ptr.semaphore_write_mutex);
|
||||||
|
}
|
||||||
|
@ -192,29 +192,6 @@ const QString lamexp_version2string(const QString &pattern, unsigned int version
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Free all registered tools (final clean-up)
|
|
||||||
*/
|
|
||||||
void lamexp_clean_all_tools(void)
|
|
||||||
{
|
|
||||||
if(g_lamexp_tools.registry)
|
|
||||||
{
|
|
||||||
QStringList keys = g_lamexp_tools.registry->keys();
|
|
||||||
for(int i = 0; i < keys.count(); i++)
|
|
||||||
{
|
|
||||||
LockedFile *lf = g_lamexp_tools.registry->take(keys.at(i));
|
|
||||||
LAMEXP_DELETE(lf);
|
|
||||||
}
|
|
||||||
g_lamexp_tools.registry->clear();
|
|
||||||
g_lamexp_tools.versions->clear();
|
|
||||||
g_lamexp_tools.tags->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
LAMEXP_DELETE(g_lamexp_tools.registry);
|
|
||||||
LAMEXP_DELETE(g_lamexp_tools.versions);
|
|
||||||
LAMEXP_DELETE(g_lamexp_tools.tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize translations and add default language
|
* Initialize translations and add default language
|
||||||
*/
|
*/
|
||||||
@ -364,28 +341,6 @@ bool lamexp_install_translator_from_file(const QString &qmFile)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Free all registered translations (final clean-up)
|
|
||||||
*/
|
|
||||||
void lamexp_clean_all_translations(void)
|
|
||||||
{
|
|
||||||
QWriteLocker writeLockTranslator(&g_lamexp_currentTranslator.lock);
|
|
||||||
|
|
||||||
if(g_lamexp_currentTranslator.instance)
|
|
||||||
{
|
|
||||||
QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
|
|
||||||
LAMEXP_DELETE(g_lamexp_currentTranslator.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeLockTranslator.unlock();
|
|
||||||
QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);
|
|
||||||
|
|
||||||
LAMEXP_DELETE(g_lamexp_translation.files);
|
|
||||||
LAMEXP_DELETE(g_lamexp_translation.names);
|
|
||||||
LAMEXP_DELETE(g_lamexp_translation.cntry);
|
|
||||||
LAMEXP_DELETE(g_lamexp_translation.sysid);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// INITIALIZATION
|
// INITIALIZATION
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -396,3 +351,39 @@ extern "C" void _lamexp_global_init_tools(void)
|
|||||||
LAMEXP_ZERO_MEMORY(g_lamexp_currentTranslator);
|
LAMEXP_ZERO_MEMORY(g_lamexp_currentTranslator);
|
||||||
LAMEXP_ZERO_MEMORY(g_lamexp_translation);
|
LAMEXP_ZERO_MEMORY(g_lamexp_translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FINALIZATION
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" void _lamexp_global_free_tools(void)
|
||||||
|
{
|
||||||
|
//Free *all* registered translations
|
||||||
|
if(g_lamexp_currentTranslator.instance)
|
||||||
|
{
|
||||||
|
QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
|
||||||
|
LAMEXP_DELETE(g_lamexp_currentTranslator.instance);
|
||||||
|
}
|
||||||
|
LAMEXP_DELETE(g_lamexp_translation.files);
|
||||||
|
LAMEXP_DELETE(g_lamexp_translation.names);
|
||||||
|
LAMEXP_DELETE(g_lamexp_translation.cntry);
|
||||||
|
LAMEXP_DELETE(g_lamexp_translation.sysid);
|
||||||
|
|
||||||
|
//Free *all* registered tools
|
||||||
|
if(g_lamexp_tools.registry)
|
||||||
|
{
|
||||||
|
QStringList keys = g_lamexp_tools.registry->keys();
|
||||||
|
for(int i = 0; i < keys.count(); i++)
|
||||||
|
{
|
||||||
|
LockedFile *lf = g_lamexp_tools.registry->take(keys.at(i));
|
||||||
|
LAMEXP_DELETE(lf);
|
||||||
|
}
|
||||||
|
g_lamexp_tools.registry->clear();
|
||||||
|
g_lamexp_tools.versions->clear();
|
||||||
|
g_lamexp_tools.tags->clear();
|
||||||
|
}
|
||||||
|
LAMEXP_DELETE(g_lamexp_tools.registry);
|
||||||
|
LAMEXP_DELETE(g_lamexp_tools.versions);
|
||||||
|
LAMEXP_DELETE(g_lamexp_tools.tags);
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -187,15 +187,6 @@ const QString &lamexp_temp_folder2(void)
|
|||||||
return *g_lamexp_temp_folder.path;
|
return *g_lamexp_temp_folder.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear LameXP temp folder cache
|
|
||||||
*/
|
|
||||||
void lamexp_temp_folder_clear(void)
|
|
||||||
{
|
|
||||||
QWriteLocker writeLock(&g_lamexp_temp_folder.lock);
|
|
||||||
LAMEXP_DELETE(g_lamexp_temp_folder.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup QPorcess object
|
* Setup QPorcess object
|
||||||
*/
|
*/
|
||||||
@ -614,3 +605,35 @@ extern "C" void _lamexp_global_init_utils(void)
|
|||||||
LAMEXP_ZERO_MEMORY(g_lamexp_temp_folder);
|
LAMEXP_ZERO_MEMORY(g_lamexp_temp_folder);
|
||||||
LAMEXP_ZERO_MEMORY(g_lamexp_app_icon);
|
LAMEXP_ZERO_MEMORY(g_lamexp_app_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FINALIZATION
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" void _lamexp_global_free_utils(void)
|
||||||
|
{
|
||||||
|
//Delete temporary files
|
||||||
|
const QString &tempFolder = lamexp_temp_folder2();
|
||||||
|
if(!tempFolder.isEmpty())
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
for(int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
if(lamexp_clean_folder(tempFolder))
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
lamexp_sleep(100);
|
||||||
|
}
|
||||||
|
if(!success)
|
||||||
|
{
|
||||||
|
lamexp_system_message(L"Sorry, LameXP was unable to clean up all temporary files. Some residual files in your TEMP directory may require manual deletion!", lamexp_beep_warning);
|
||||||
|
lamexp_exec_shell(NULL, tempFolder, QString(), QString(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Free memory
|
||||||
|
LAMEXP_DELETE(g_lamexp_temp_folder.path);
|
||||||
|
LAMEXP_DELETE(g_lamexp_app_icon.appIcon);
|
||||||
|
}
|
||||||
|
@ -325,3 +325,12 @@ extern "C" void _lamexp_global_init_versn(void)
|
|||||||
{
|
{
|
||||||
LAMEXP_ZERO_MEMORY(g_lamexp_portable);
|
LAMEXP_ZERO_MEMORY(g_lamexp_portable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FINALIZATION
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" void _lamexp_global_free_versn(void)
|
||||||
|
{
|
||||||
|
/*nothing to do here*/
|
||||||
|
}
|
||||||
|
@ -1491,6 +1491,23 @@ QDate lamexp_current_date_safe(void)
|
|||||||
return (currentDate >= processDate) ? currentDate : processDate;
|
return (currentDate >= processDate) ? currentDate : processDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show system message box
|
||||||
|
*/
|
||||||
|
int lamexp_system_message(const wchar_t *text, int beepType)
|
||||||
|
{
|
||||||
|
UINT flags = MB_OK | MB_TOPMOST;
|
||||||
|
|
||||||
|
switch(beepType)
|
||||||
|
{
|
||||||
|
case lamexp_beep_info: flags = flags | MB_ICONASTERISK;
|
||||||
|
case lamexp_beep_warning: flags = flags | MB_ICONEXCLAMATION;
|
||||||
|
case lamexp_beep_error: flags = flags | MB_ICONHAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MessageBoxW(NULL, text, L"LameXP", flags);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Suspend calling thread for N milliseconds
|
* Suspend calling thread for N milliseconds
|
||||||
*/
|
*/
|
||||||
@ -1735,10 +1752,16 @@ unsigned __int64 lamexp_current_file_time(void)
|
|||||||
/*
|
/*
|
||||||
* Bring the specifed window to the front
|
* Bring the specifed window to the front
|
||||||
*/
|
*/
|
||||||
bool lamexp_bring_to_front(const QWidget *win)
|
bool lamexp_bring_to_front(const QWidget *window)
|
||||||
{
|
{
|
||||||
const bool ret = (SetForegroundWindow(win->winId()) == TRUE);
|
bool ret = false;
|
||||||
SwitchToThisWindow(win->winId(), TRUE);
|
|
||||||
|
if(window)
|
||||||
|
{
|
||||||
|
ret = (SetForegroundWindow(window->winId()) == TRUE);
|
||||||
|
SwitchToThisWindow(window->winId(), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2027,7 +2050,7 @@ bool lamexp_sheet_of_glass_update(QWidget *window)
|
|||||||
/*
|
/*
|
||||||
* Update the window icon
|
* Update the window icon
|
||||||
*/
|
*/
|
||||||
bool lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon)
|
lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBigIcon)
|
||||||
{
|
{
|
||||||
if(!icon.isNull())
|
if(!icon.isNull())
|
||||||
{
|
{
|
||||||
@ -2035,11 +2058,21 @@ bool lamexp_set_window_icon(QWidget *window, const QIcon &icon, const bool bIsBi
|
|||||||
if(HICON hIcon = lamexp_qicon2hicon(icon, extend, extend))
|
if(HICON hIcon = lamexp_qicon2hicon(icon, extend, extend))
|
||||||
{
|
{
|
||||||
SendMessage(window->winId(), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
|
SendMessage(window->winId(), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
|
||||||
//DestroyIcon(hIcon); /*FIXME: Destroying the icon here will remove it from the window*/
|
return reinterpret_cast<lamexp_icon_t*>(hIcon);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free window icon
|
||||||
|
*/
|
||||||
|
void lamexp_free_window_icon(lamexp_icon_t *icon)
|
||||||
|
{
|
||||||
|
if(HICON hIcon = reinterpret_cast<HICON>(icon))
|
||||||
|
{
|
||||||
|
DestroyIcon(hIcon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2102,85 +2135,6 @@ void lamexp_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessag
|
|||||||
Sleep(INFINITE);
|
Sleep(INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Finalization function (final clean-up)
|
|
||||||
*/
|
|
||||||
void lamexp_finalization(void)
|
|
||||||
{
|
|
||||||
qDebug("lamexp_finalization()");
|
|
||||||
|
|
||||||
//Free all tools
|
|
||||||
lamexp_clean_all_tools();
|
|
||||||
|
|
||||||
//Delete temporary files
|
|
||||||
const QString &tempFolder = lamexp_temp_folder2();
|
|
||||||
if(!tempFolder.isEmpty())
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
for(int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
if(lamexp_clean_folder(tempFolder))
|
|
||||||
{
|
|
||||||
success = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lamexp_sleep(100);
|
|
||||||
}
|
|
||||||
if(!success)
|
|
||||||
{
|
|
||||||
MessageBoxW(NULL, L"Sorry, LameXP was unable to clean up all temporary files. Some residual files in your TEMP directory may require manual deletion!", L"LameXP", MB_ICONEXCLAMATION|MB_TOPMOST);
|
|
||||||
lamexp_exec_shell(NULL, tempFolder, QString(), QString(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Clear folder cache
|
|
||||||
LAMEXP_DELETE(g_lamexp_known_folder.knownFolders);
|
|
||||||
|
|
||||||
//Clear languages
|
|
||||||
lamexp_clean_all_translations();
|
|
||||||
|
|
||||||
//Destroy Qt application object
|
|
||||||
QApplication *application = dynamic_cast<QApplication*>(QApplication::instance());
|
|
||||||
LAMEXP_DELETE(application);
|
|
||||||
|
|
||||||
//Release DWM API
|
|
||||||
g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
|
|
||||||
g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
|
|
||||||
LAMEXP_DELETE(g_lamexp_dwmapi.dwmapi_dll);
|
|
||||||
|
|
||||||
//Detach from shared memory
|
|
||||||
lamexp_ipc_exit();
|
|
||||||
|
|
||||||
//Free STDOUT and STDERR buffers
|
|
||||||
if(g_lamexp_console_attached)
|
|
||||||
{
|
|
||||||
if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cout.rdbuf()))
|
|
||||||
{
|
|
||||||
std::cout.rdbuf(NULL);
|
|
||||||
LAMEXP_DELETE(tmp);
|
|
||||||
}
|
|
||||||
if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cerr.rdbuf()))
|
|
||||||
{
|
|
||||||
std::cerr.rdbuf(NULL);
|
|
||||||
LAMEXP_DELETE(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Close log file
|
|
||||||
if(g_lamexp_log_file)
|
|
||||||
{
|
|
||||||
fclose(g_lamexp_log_file);
|
|
||||||
g_lamexp_log_file = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Free CLI Arguments
|
|
||||||
LAMEXP_DELETE(g_lamexp_argv.list);
|
|
||||||
|
|
||||||
//Free TEMP folder
|
|
||||||
lamexp_temp_folder_clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize debug thread
|
* Initialize debug thread
|
||||||
*/
|
*/
|
||||||
@ -2238,3 +2192,48 @@ extern "C" void _lamexp_global_init_win32(void)
|
|||||||
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
|
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
|
||||||
LAMEXP_ZERO_MEMORY(g_lamexp_dwmapi);
|
LAMEXP_ZERO_MEMORY(g_lamexp_dwmapi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// FINALIZATION
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern "C" void _lamexp_global_free_win32(void)
|
||||||
|
{
|
||||||
|
//Clear folder cache
|
||||||
|
LAMEXP_DELETE(g_lamexp_known_folder.knownFolders);
|
||||||
|
|
||||||
|
//Destroy Qt application object
|
||||||
|
QApplication *application = dynamic_cast<QApplication*>(QApplication::instance());
|
||||||
|
LAMEXP_DELETE(application);
|
||||||
|
|
||||||
|
//Release DWM API
|
||||||
|
g_lamexp_dwmapi.dwmIsCompositionEnabled = NULL;
|
||||||
|
g_lamexp_dwmapi.dwmExtendFrameIntoClientArea = NULL;
|
||||||
|
g_lamexp_dwmapi.dwmEnableBlurBehindWindow = NULL;
|
||||||
|
LAMEXP_DELETE(g_lamexp_dwmapi.dwmapi_dll);
|
||||||
|
|
||||||
|
//Free STDOUT and STDERR buffers
|
||||||
|
if(g_lamexp_console_attached)
|
||||||
|
{
|
||||||
|
if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cout.rdbuf()))
|
||||||
|
{
|
||||||
|
std::cout.rdbuf(NULL);
|
||||||
|
LAMEXP_DELETE(tmp);
|
||||||
|
}
|
||||||
|
if(std::filebuf *tmp = dynamic_cast<std::filebuf*>(std::cerr.rdbuf()))
|
||||||
|
{
|
||||||
|
std::cerr.rdbuf(NULL);
|
||||||
|
LAMEXP_DELETE(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Close log file
|
||||||
|
if(g_lamexp_log_file)
|
||||||
|
{
|
||||||
|
fclose(g_lamexp_log_file);
|
||||||
|
g_lamexp_log_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Free CLI Arguments
|
||||||
|
LAMEXP_DELETE(g_lamexp_argv.list);
|
||||||
|
}
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// GLOBAL FUNCTIONS
|
// GLOBAL FUNCTIONS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -44,7 +46,7 @@ static size_t lamexp_entry_check(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application entry point (runs before static initializers)
|
* Function declarations
|
||||||
*/
|
*/
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -56,24 +58,49 @@ extern "C"
|
|||||||
void _lamexp_global_init_ipcom(void);
|
void _lamexp_global_init_ipcom(void);
|
||||||
void _lamexp_global_init_utils(void);
|
void _lamexp_global_init_utils(void);
|
||||||
|
|
||||||
int lamexp_entry_point(void)
|
void _lamexp_global_free_win32(void);
|
||||||
{
|
void _lamexp_global_free_versn(void);
|
||||||
if(g_lamexp_entry_check_flag != 0x789E09B2)
|
void _lamexp_global_free_tools(void);
|
||||||
{
|
void _lamexp_global_free_ipcom(void);
|
||||||
lamexp_fatal_exit(L"Application initialization has failed, take care!");
|
void _lamexp_global_free_utils(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Call global initialization functions
|
/*
|
||||||
_lamexp_global_init_win32();
|
* Application entry point (runs before static initializers)
|
||||||
_lamexp_global_init_versn();
|
*/
|
||||||
_lamexp_global_init_tools();
|
|
||||||
_lamexp_global_init_ipcom();
|
extern "C" int lamexp_entry_point(void)
|
||||||
_lamexp_global_init_utils();
|
{
|
||||||
|
if(g_lamexp_entry_check_flag != 0x789E09B2)
|
||||||
//Make sure we will pass the check
|
{
|
||||||
g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
|
lamexp_fatal_exit(L"Application initialization has failed, take care!");
|
||||||
|
}
|
||||||
//Now initialize the C Runtime library!
|
|
||||||
return WinMainCRTStartup();
|
//Call global initialization functions
|
||||||
}
|
_lamexp_global_init_win32();
|
||||||
|
_lamexp_global_init_versn();
|
||||||
|
_lamexp_global_init_tools();
|
||||||
|
_lamexp_global_init_ipcom();
|
||||||
|
_lamexp_global_init_utils();
|
||||||
|
|
||||||
|
//Make sure we will pass the check
|
||||||
|
g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
|
||||||
|
|
||||||
|
//Now initialize the C Runtime library!
|
||||||
|
return WinMainCRTStartup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application finalization function
|
||||||
|
*/
|
||||||
|
void lamexp_finalization(void)
|
||||||
|
{
|
||||||
|
qDebug("lamexp_finalization()");
|
||||||
|
|
||||||
|
//Call global finalization functions, in proper order
|
||||||
|
_lamexp_global_free_versn();
|
||||||
|
_lamexp_global_free_tools();
|
||||||
|
_lamexp_global_free_ipcom();
|
||||||
|
_lamexp_global_free_utils();
|
||||||
|
_lamexp_global_free_win32();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user