Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - UnderPlayer

#1
Help requests / Connecting multiple signals
29 July 2019, 21:06:57
Hello there,

I just wondered, in previous versions you were able to write code like

Code (cpp) Select
my_checkbox->connect("checked unchecked", [](bool status){ std::cout << status << '\n'; });

I had a look into the code and found that - since version 0.8 - the connect function got "simplified" to

Code (cpp) Select

        const unsigned int id = getSignal(toLower(signalName)).connect([f=std::function<void(const Args&...)>(handler),args...](){ f(args...); });
        m_connectedSignals[id] = toLower(signalName);
        return id;


or one of its sibblings. So, when writing the code mentioned above you will get an error that reads "There is no signal called 'checked unchecked'". Why did that behaviour get changed? What would be the best way to accomplish the previous behaviour?

Lars
#2
Hi fellow programmers, artists and humans,

today - experiencing the calmness and beauty of modern programming in C++ - I stumbled upon something. "What was it?" you might ask. And my answer would be: I don't know. It was just there and I had no clue where it came from or what it means. My compiler would give me an oddly unspecific error that reads "Internal Compiler Error". So after a short investigation I came to the conclusion that I still had no idea.

Okay, I will stop that now and give some specific information including a minimal example, that reproduces the error for me.
C++ 17
SFML: 2.5.1
TGUI: 0.8.5
Visual C: 14.21.27702
Visual Studio 2019 16.1.6
Build Config: Debug and Release

The error message (partly, because most of it is german in my case. It just says try contacting microsofts support hotline or change the code in some way.):

Error C1001 Internal Compilererror.
(Compilerfile "d:\agent\_work\4\s\src\vctools\Compiler\CxxFE\sl\p1\c\PackExpander.cpp", line 1764)
MenuItemTest C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include\TGUI\SignalImpl.hpp 148


Code (cpp) Select

#include <TGUI/TGUI.hpp>

int main()
{
auto menu = tgui::MenuBar::create();
menu->addMenuItem({ "Test" }, true);
menu->connectMenuItem(
{ "Test" },
[]() { printf_s("works\n"); }
);
}


I'm quite sure that the function used to work for me, but now it does not anymore. I've never encountered that error before and my first bet would be, that something is off, so that the compiler doesn't know how to interpret the code in front of it.

Anyway, I hope someone here has an idea or maybe someone encountered the same problem and knows a solution.

Lars