Re: Which dialog classes can function without a top-level frame?
Sean Tolstoyevski <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <CAJkz5powU_fKw7Spu5r42T6=SVF_4WC9dBcjbtxYbtVHFw5nwg@mail.gmail.com> |
Thank you for your answer.
I looked what you said (
https://docs.wxwidgets.org/3.2/group__group__funcmacro__appinitterm.html)
and tried different things. However, the program continues to give
segmentation faults.
Here is the new version of the code:
```c++
#define BIGA_EXPORTS
#include "biga/ui/native/message_box.hpp"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/aboutdlg.h"
#include "wx/app.h"
#include "biga/internal/log.hpp"
#include "wx/button.h"
#include "wx/msgdlg.h"
namespace biga::ui::native
{
BIGA_EXPORT
bool Initialize(int argCount, const char *argList[]) noexcept
{
SPDLOG_DEBUG("called");
return wxInitialize(argCount, const_cast<char **>(argList));
// i am tried thats but doesn't work:
// return wxEntryStart(argCount, const_cast<char **>(argList));
// wxInitialize(argCount,
// const_cast<char **>(argList));
}
BIGA_EXPORT
void NativeAboutBox(const std::string programName,
const std::string &proVversion,
const std::string &progDescription,
const std::string ©right,
const std::string &licence, const std::string &webSite)
{
SPDLOG_DEBUG("called");
wxAboutDialogInfo info;
info.SetName(programName);
info.SetVersion(proVversion);
info.SetDescription(progDescription);
info.SetCopyright(copyright);
info.SetWebSite(webSite);
info.SetLicence(licence);
wxAboutBox(info, nullptr);
SPDLOG_DEBUG("end");
}
} // namespace biga::ui::native
```
usage code (main.cpp):
```c++
#include <iostream>
#include "biga/ui/native/about_box.hpp"
#include "biga/ui/native/native.hpp"
int main(int argCount, const char* argList[])
{
if (! biga::ui::native::Initialize(argCount, argList))
{
std::cerr << "Failed to initialize native UI" << std::endl;
return 1;
}
std::cout << "wxwidgets initialized\n";
// initialize is successful, not problem.
biga::ui::native::NativeAboutBox(
"Biga", "v b1.4", "this is a description",
"copyright seantolstoyevski and all contrubitors.", "",
"https://github.com/seantolstoyevski/biga");
return 0;
}
```
gdb output:
```c++
D:\projs\biga\build>gdb NativeUIAboutbox.exe
GNU gdb (GDB) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from NativeUIAboutbox.exe...
(gdb) r
Starting program: D:\projs\biga\build\NativeUIAboutbox.exe
[New Thread 14556.0x1124c]
[New Thread 14556.0xc4b0]
[New Thread 14556.0x15c20]
wxwidgets initialized
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff9ba3ef894 in wxApp::MSWGetDefaultLayout (parent=0x0)
at D:\projs\biga\third_party\wxwidgets\src\msw\app.cpp:1034
1034 dir = wxTheApp->GetLayoutDirection();
(gdb)
```
Vadim Zeitlin <[email protected]>, 14 Eyl 2024 Cmt, 16:08 tarihinde şunu
yazdı:
> On Sat, 14 Sep 2024 16:00:34 +0300 Sean Tolstoyevski wrote:
>
> ST> 1. Which dialog classes can operate without a top-level frame (i.e.,
> ST> without a parent panel)?
>
> All dialogs should be able to operate without a parent.
>
> ST> However, in my experiments, wxAboutDialogInfo doesn't seem to
> ST> behave as expected.
>
> This is almost certainly due to the fact that you don't initialize the
> library correctly (at least if your main function is complete). You must
> initialize it using either wxInitializer or explicit wxEntryStart() call
> and without this nothing, even wxMessageBox, is guaranteed to work (and, in
> fact, wxMessageBox won't work in wxGTK, for example, because you won't have
> any connection to X/Wayland display server before you initialize the
> library).
>
> Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
> https://www.tt-solutions.com/
>
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/CAJkz5powU_fKw7Spu5r42T6%3DSVF_4WC9dBcjbtxYbtVHFw5nwg%40mail.gmail.com.