Project

General

Profile

Actions

Improvements #9204

closed

Feature #7418: Bootstrap 5 theme

Bootstrap themes require an active WApplication upon construction for proper operation

Added by Roel Standaert over 2 years ago. Updated about 2 years ago.

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

100%

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.

Actions #1

Updated by Roel Standaert over 2 years 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
Actions #2

Updated by Rathnadhar K V over 2 years 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

Actions #3

Updated by Roel Standaert over 2 years 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.

Actions #4

Updated by Roel Standaert over 2 years ago

  • Target version changed from future to 4.7.0
Actions #5

Updated by Korneel Dumon over 2 years ago

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

Updated by Roel Standaert over 2 years 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.

Actions #7

Updated by Roel Standaert about 2 years ago

  • % Done changed from 0 to 100
Actions #8

Updated by Roel Standaert about 2 years ago

  • Status changed from InProgress to Resolved
Actions #9

Updated by Roel Standaert about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF