Skip to content

Commit

Permalink
Fixes segfault on closing app
Browse files Browse the repository at this point in the history
* thread PokemonAutomation#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010070ef98 QtWidgets`QApplication::~QApplication() + 564
QtWidgets`QApplication::~QApplication:
->  0x10070ef98 <+564>: ldr    x0, [x0]
    0x10070ef9c <+568>: str    x20, [x8]
    0x10070efa0 <+572>: ldr    w8, [x0, #0x10]
    0x10070efa4 <+576>: cmn    w8, #0x1
Target 0: (HexGenerator) stopped.
(lldb) bt
* thread PokemonAutomation#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010070ef98 QtWidgets`QApplication::~QApplication() + 564
    frame PokemonAutomation#1: 0x000000010070f128 QtWidgets`QApplication::~QApplication() + 12
    frame PokemonAutomation#2: 0x0000000100042248 HexGenerator`std::__1::unique_ptr<QApplication, std::__1::default_delete<QApplication> >::~unique_ptr() + 40
    frame PokemonAutomation#3: 0x00000001af27ffd8 libsystem_c.dylib`__cxa_finalize_ranges + 464
    frame PokemonAutomation#4: 0x00000001af27fd6c libsystem_c.dylib`exit + 44
    frame PokemonAutomation#5: 0x00000001af3aef7c libdyld.dylib`dyld4::LibSystemHelpers::exit(int) const + 20
    frame PokemonAutomation#6: 0x00000001af06be9c dyld`start + 2620
  • Loading branch information
naussika committed Mar 6, 2023
1 parent 1ba9259 commit 94aae07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions HexGenerator/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace PokemonAutomation{
namespace HexGenerator{

std::unique_ptr<QApplication> application;
QApplication* application = nullptr;

}
}
Expand All @@ -27,7 +27,8 @@ using namespace HexGenerator;
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
application.reset(new QApplication(argc, argv));
auto app = std::make_unique<QApplication>(argc, argv);
application = app.get();

settings.load();

Expand Down Expand Up @@ -57,7 +58,7 @@ int main(int argc, char *argv[])

MainWindow w;
w.show();
int ret = application->exec();
int ret = app->exec();
settings.write();
return ret;
}
4 changes: 2 additions & 2 deletions HexGenerator/Source/Tools/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ int build_hexfile(



extern std::unique_ptr<QApplication> application;
extern QApplication* application;

template <typename Lambda>
void run_on_main_thread(Lambda&& lambda){
QMetaObject::invokeMethod(application.get(), std::move(lambda));
QMetaObject::invokeMethod(application, std::move(lambda));
}


Expand Down

0 comments on commit 94aae07

Please sign in to comment.