-
-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt freezes when displaying native dialogs with briefcase>=0.3.9 #930
Qt freezes when displaying native dialogs with briefcase>=0.3.9 #930
Comments
Thanks for the report. It certainly seems to point to a problem with the stub app; if the app generally works, but dialogs don't, it suggests to me that the threading mode on the main executable hasn't been set correctly. I'm at a conference right now so I don't have access to my Windows box for testing; but it's possible this might affect Toga dialogs as well. |
Enjoy the conference! I just tested with |
I've taken this as far as I can go. TLDR: can you please include Long story: It took some time to figure out the console thing which wasn't working from the terminal. I needed some extra code. For reference: HANDLE stdHandle;
int hConsole;
FILE* fp;
AttachConsole(ATTACH_PARENT_PROCESS);
stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
hConsole = _open_osfhandle( (long)stdHandle, _O_TEXT);
fp = _fdopen(hConsole, "w");
_wfreopen_s( &fp, L"CONOUT$", L"w", stdout);
_wfreopen_s( &fp, L"CONOUT$", L"w", stderr); Anyway, the following simple fix (should've trusted StackOverflow sooner) works: just add this line to the top of CoUninitialize(); This will uninitialize the thread model. I have confirmed, by calling #include <cstdio>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
int Main() {
HANDLE stdHandle;
int hConsole;
FILE* fp;
HRESULT hr;
// CoUninitialize();
AttachConsole(ATTACH_PARENT_PROCESS);
stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
hConsole = _open_osfhandle( (long)stdHandle, _O_TEXT);
fp = _fdopen(hConsole, "w");
_wfreopen_s( &fp, L"CONOUT$", L"w", stdout);
_wfreopen_s( &fp, L"CONOUT$", L"w", stderr);
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (hr == S_OK) printf("Was not yet called\n");
if (hr == S_FALSE) printf("Was already called\n");
if (hr == RPC_E_CHANGED_MODE) printf("Different mode\n");
return 0;
} and tried to slim down the |
Just to be sure, I checked if a simple Mind that in order to use |
This is awesome debugging, @davidfokkema - thanks! AFAICT, this is exactly what is needed; adding this extra line doesn't disrupt anything with the crash dialog or Toga's own behavior, and I can confirm it also fixes the issue for me on Qt - so I'll call that a significant win! I've just opened beeware/briefcase-windows-VisualStudio-template#11 to incorporate this change; you should be able to test that yourself by adding |
Works like a charm! 😃 |
@davidfokkema I've just merged the VisualStudio template change, and rebuilt the stub apps on the app template. The patches have also been back ported to the v0.3.12 template branches. Let me know if you have any problems. |
My app builds and works perfectly now on briefcase 0.3.12, freezes after a downgrade to 0.3.11 and works again after upgrading to 0.3.12. I tested that cycle just to make sure I had no modifications floating around and that stock briefcase 0.3.12 fixes the issue. It does, so I’m very happy. Thanks!! |
When using Qt as the GUI toolkit, my app freezes when displaying a native dialog. For example, this code freezes my app:
This only happens when executing
briefcase run
; runningbriefcase dev
results in the expected behaviour. Also, it only does not work while executing in the main event loop. During UI class instantiation, it is no problem to display the dialog. Also, when you explicitly ask for a non-native dialog,QFileDialog()
works fine. Older briefcases work without problems so I suspect it has something to do with the new stub app approach.Steps to reproduce the behavior:
app.py
class as follows:Expected behavior
I expect the native file dialog to be displayed without problems.
Environment:
The text was updated successfully, but these errors were encountered: