Actions
Bug #5887
closedCrash with WTimePicker
Start date:
08/23/2017
Due date:
% Done:
0%
Estimated time:
Description
Hi ! I have a crash with WTimeEdit::setTime :
#include <Wt/WApplication.h>
#include <Wt/WEnvironment.h>
#include <Wt/WTimeEdit.h>
class TestApplication : public Wt::WApplication
{
public:
TestApplication(const Wt::WEnvironment& env);
~TestApplication() { }
};
TestApplication::TestApplication(const Wt::WEnvironment& env) : Wt::WApplication(env)
{
setTitle("Test WTimeEdit");
Wt::WTimeEdit * te = new Wt::WTimeEdit();
root()->addWidget(std::unique_ptr<Wt::WWidget>(te));
te->setFormat("HH:mm");
Wt::WTime tmp (23, 30);
// CRASHES HERE
te->setTime(tmp);
}
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
return Wt::cpp14::make_unique<TestApplication>(env);
});
}
So i propose this patch :
diff --git a/src/Wt/WTimePicker.C b/src/Wt/WTimePicker.C
index 818c240..5ab5510 100644
--- a/src/Wt/WTimePicker.C
+++ b/src/Wt/WTimePicker.C
@@ -102,7 +102,10 @@ void WTimePicker::setTime(const WTime& time)
sbhour_->setValue(hours);
sbminute_->setValue(minutes);
- sbsecond_->setValue(seconds);
+
+ if (formatS()) {
+ sbsecond_->setValue(seconds);
+ }
if (formatMs()) {
sbmillisecond_->setValue(millisecond);
Updated by Roel Standaert over 7 years ago
- Status changed from Resolved to Closed
Actions