QCoreApplicationPrivate: use std::unique_ptr for origArgv

Change-Id: Id03feb55d3c3899aa4fffffdc0b3ee7b0742f9e8
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 981c2e8b746a9fb41164e6911d1609119bf1c600)
This commit is contained in:
Thiago Macieira 2025-01-13 04:37:51 -08:00
parent b9e8a966ea
commit 37dbdd9b58
2 changed files with 5 additions and 4 deletions

View File

@ -435,8 +435,8 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv)
#if defined(Q_OS_WIN)
if (!isArgvModified(argc, argv)) {
origArgc = argc;
origArgv = new char *[argc];
std::copy(argv, argv + argc, QT_MAKE_CHECKED_ARRAY_ITERATOR(origArgv, argc));
origArgv = q20::make_unique_for_overwrite<char *[]>(argc);
std::copy(argv, argv + argc, origArgv.get());
}
#endif // Q_OS_WIN
@ -460,7 +460,6 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate()
cleanupThreadData();
#endif
#if defined(Q_OS_WIN)
delete [] origArgv;
cleanupDebuggingConsole();
#endif
QCoreApplicationPrivate::clearApplicationFilePath();

View File

@ -127,8 +127,10 @@ public:
int &argc;
char **argv;
#if defined(Q_OS_WIN)
// store unmodified arguments for QCoreApplication::arguments()
int origArgc = 0;
char **origArgv = nullptr; // store unmodified arguments for QCoreApplication::arguments()
std::unique_ptr<char *[]> origArgv;
bool consoleAllocated = false;
#endif
void appendApplicationPathToLibraryPaths(void);