Project

General

Profile

Improvements #9204

Feature #7418: Bootstrap 5 theme

Bootstrap themes require an active WApplication upon construction for proper operation

Added by Roel Standaert about 2 months ago. Updated 11 days ago.

Status:
InProgress
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 about 2 months 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 1 month 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

#3

Updated by Roel Standaert about 1 month ago

WApplication::instance() returns a pointer to the current WApplication in the current thread (we use a thread local variable for that), so it's not as nasty as you think it may be.

#4

Updated by Roel Standaert about 1 month ago

  • Target version changed from future to 4.7.0
#5

Updated by Korneel Dumon about 1 month ago

  • Status changed from New to InProgress
  • Assignee set to Korneel Dumon
#6

Updated by Roel Standaert 11 days ago

  • Target version changed from 4.7.0 to 4.6.0
  • Parent task changed from #9207 to #7418

This code has been integrated into the bootstrap5 branch, so I'm moving this to the issue that tracks Bootstrap 5 rather than the follow-up.

Also available in: Atom PDF