Improvements #9204
closedFeature #7418: Bootstrap 5 theme
Bootstrap themes require an active WApplication upon construction for proper operation
100%
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
.
Updated by Roel Standaert about 3 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
Updated by Rathnadhar K V about 3 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
Updated by Roel Standaert about 3 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.
Updated by Roel Standaert about 3 years ago
- Target version changed from future to 4.7.0
Updated by Korneel Dumon about 3 years ago
- Status changed from New to InProgress
- Assignee set to Korneel Dumon
Updated by Roel Standaert about 3 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.
Updated by Roel Standaert almost 3 years ago
- Status changed from InProgress to Resolved
Updated by Roel Standaert almost 3 years ago
- Status changed from Resolved to Closed