Project

General

Profile

Improvements #9204

Improvements #9207: Follow up on Bootstrap 4 and 5 themes

Bootstrap themes require an active WApplication upon construction for proper operation

Added by Roel Standaert 3 days ago. Updated about 5 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
10/14/2021
Due date:
% Done:

0%

Estimated time:

Description

The themes are placed in a shared_ptr and thus in theory are stateless and can be shared between several instances of WApplication.

However, the constructor of the Bootstrap themes actually adds builtin XML strings to the active WApplication, basically requiring them to be
created in the constructor of the WApplication.

We should probably have some virtual function that takes care of this, and is automatically called in WApplication::setTheme.

#1

Updated by Roel Standaert 3 days ago

  • Subject changed from Bootstrap themes require an active WApplication upon construction for proper opration to Bootstrap themes require an active WApplication upon construction for proper operation
  • Parent task set to #9207
#2

Updated by Rathnadhar K V about 5 hours ago

Namaskara Roel,

I noticed this fact.

I read the code and in the constructor and applyValidationStyle()

WApplication *app = WApplication::instance();

Now WApplication::instance() is a static function.

I abhor static functions.

I then modified the WBoostrapTheme where the WApplication pointer is passed as C'tor parameter.

WBootstrapTheme(Wt::WApplication*      in_app_ptr,
                Wt::BootstrapVersion   in_bootstrapversion,
                bool                   in_responsive,
                bool                   in_formControlStyle
               );

I store the Application* as private member variable.

I tested the above C'tor. It worked beautifully.

Since I set the Bootstrap version, responsiveness and formcontrolstyle in c'tor itself, my code is that much compact and robust.

I dont have to set the WApplication* repeatedly.

Maybe this helps.

Further, I would replace Shared_ptr with unique_ptr& that way the invocation is that much quicker. Please give that a thought.

Regards
Rathnadhar KV

Also available in: Atom PDF