C++: make Platform::duration_since_start non-const and pure

When SLINT_FEATURE_FREESTANDING is set, it must be re-implemented
otherwise the time doesn't pass
This commit is contained in:
Olivier Goffart 2023-08-30 13:47:56 +02:00 committed by Olivier Goffart
parent c47e6cd029
commit 932db7ac38
3 changed files with 5 additions and 8 deletions

View file

@ -343,10 +343,7 @@ public:
///
/// This function should only be implemented if the runtime is compiled with
/// SLINT_FEATURE_FREESTANDING
virtual std::chrono::milliseconds duration_since_start() const
{
return {};
}
virtual std::chrono::milliseconds duration_since_start() = 0;
#endif
/// The type of clipboard used in Platform::clipboard_text and PLatform::set_clipboard_text.
@ -449,7 +446,7 @@ inline void set_platform(std::unique_ptr<Platform> platform)
#ifndef SLINT_FEATURE_FREESTANDING
return 0;
#else
return reinterpret_cast<const Platform *>(p)->duration_since_start().count();
return reinterpret_cast<Platform *>(p)->duration_since_start().count();
#endif
},
[](void *p, const SharedString *text, cbindgen_private::Clipboard clipboard) {