cancel
Showing results for 
Search instead for 
Did you mean: 

Touchgfx - virtual methods in the "final" Screen class

Panchev68
Senior

Hello, I need to use Touchgfx on a small CPU and I'm optimizing my code accordingly. However, in the code that Touchgfx Designer generates, I noticed something that I don't understand:
The Screen classes inherit from the ScreenBase classes.
The Screen classes are actually final, but they have virtual functions, which makes the compiler generate virtual tables for them. The same goes for the Listener classes. Does anyone have any ideas on this?
Best regards

1 ACCEPTED SOLUTION

Accepted Solutions
GaetanGodart
ST Employee

Hello @Panchev68 ,

 

When you add a screen, there will be a screenViewBase cpp and hpp files created with virtual functions but also a ScreenView cpp and hpp file.
You should not modify the base file as they get regenerated, instead you should overwrite the virtual functions by adding code in the ScreenView files (not the base files).

Is the extra computation required to look at the function table really that impactful? I don't think so, we have been able to design GUI using STM32G0 already (but without FreeRTOS).

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

2 REPLIES 2
GaetanGodart
ST Employee

Hello @Panchev68 ,

 

When you add a screen, there will be a screenViewBase cpp and hpp files created with virtual functions but also a ScreenView cpp and hpp file.
You should not modify the base file as they get regenerated, instead you should overwrite the virtual functions by adding code in the ScreenView files (not the base files).

Is the extra computation required to look at the function table really that impactful? I don't think so, we have been able to design GUI using STM32G0 already (but without FreeRTOS).

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

10 screens ~ -2Kb 

I'm asking out of simple human curiosity. I hope I missed something in C++. This solution plus a few others worked for me.
Congratulations on the wonderful environment you provide.
Best regards