Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit bdeef06

Browse files
committed
add wasm support
1 parent 2308d62 commit bdeef06

16 files changed

+62
-44
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ matrix:
2323
- PLATFORM=gcc_64
2424
- BUILD_DOC=true
2525
- BUILD_EXAMPLES=true
26+
- os: linux
27+
env:
28+
- PLATFORM=emscripten
2629
- os: linux
2730
env:
2831
- PLATFORM=android_arm64_v8a

examples/mvvmdatasynccore/DataSyncSampleCore/samplecoreapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int SampleCoreApp::startApp(const QStringList &arguments)
2929
.create();
3030
show<SampleViewModel>();
3131
return EXIT_SUCCESS;
32-
} catch (QException &e) {
32+
} catch (std::exception &e) {
3333
qCritical() << e.what();
3434
return EXIT_FAILURE;
3535
}

src/imports/mvvmquick/settingsentrymodel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ SettingsEntryModel::EntryInfo::EntryInfo(SettingsElements::Entry entry, QUrl del
168168
group(std::move(group))
169169
{
170170
static const QRegularExpression nameRegex(QStringLiteral("&(?!&)"),
171-
QRegularExpression::DontCaptureOption |
172-
QRegularExpression::OptimizeOnFirstUsageOption);
171+
QRegularExpression::DontCaptureOption);
173172
title.remove(nameRegex);
174173
this->group.entries.clear();
175174
}

src/mvvmcore/coreapp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void CoreAppPrivate::showDialog(const MessageConfig &config, MessageResult *resu
251251
try {
252252
presenter->showDialog(config, result);
253253
logDebug() << "Successfully presented dialog of type" << config.type();
254-
} catch(QException &e) {
254+
} catch(QTMVVM_EXCEPTION_BASE &e) {
255255
logCritical() << "Failed to show dialog for type"
256256
<< config.type() << ":" << config.subType()
257257
<< "with error:"
@@ -368,7 +368,7 @@ QPointer<ViewModel> CoreAppPrivate::showViewModelWithReturn(const QMetaObject *m
368368
if(isSingle)
369369
singleInstances.insert(metaObject, vm);
370370
return vm;
371-
} catch(QException &e) {
371+
} catch(QTMVVM_EXCEPTION_BASE &e) {
372372
logCritical() << "Failed to present viewmodel of type"
373373
<< metaObject->className()
374374
<< "with error:"

src/mvvmcore/exception.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef QTMVVM_EXCEPTION_H
2+
#define QTMVVM_EXCEPTION_H
3+
4+
#include "QtMvvmCore/qtmvvmcore_global.h"
5+
6+
#if !defined(QT_NO_EXCEPTIONS) && QT_CONFIG(future)
7+
#include <QtCore/QException>
8+
#define QTMVVM_EXCEPTION_BASE QException
9+
#define QTMVVM_EXCEPTION_OR override
10+
#else
11+
#include <exception>
12+
#define QTMVVM_EXCEPTION_BASE std::exception
13+
#define QTMVVM_EXCEPTION_OR
14+
#endif
15+
16+
#endif // QTMVVM_EXCEPTION_H

src/mvvmcore/ipresenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void PresenterException::raise() const
1919
throw (*this);
2020
}
2121

22-
QException *PresenterException::clone() const
22+
QTMVVM_EXCEPTION_BASE *PresenterException::clone() const
2323
{
2424
return new PresenterException(this);
2525
}

src/mvvmcore/ipresenter.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#ifndef QTMVVM_IPRESENTER_H
22
#define QTMVVM_IPRESENTER_H
33

4-
#include <QtCore/qexception.h>
5-
64
#include "QtMvvmCore/qtmvvmcore_global.h"
75
#include "QtMvvmCore/viewmodel.h"
86
#include "QtMvvmCore/message.h"
7+
#include "QtMvvmCore/exception.h"
98

109
namespace QtMvvm {
1110

1211
//! An exception to be thrown from the presenter if presenting fails
13-
class Q_MVVMCORE_EXPORT PresenterException : public QException
12+
class Q_MVVMCORE_EXPORT PresenterException : public QTMVVM_EXCEPTION_BASE
1413
{
1514
public:
1615
//! Constructor with an error message
@@ -20,9 +19,9 @@ class Q_MVVMCORE_EXPORT PresenterException : public QException
2019
const char *what() const noexcept override;
2120

2221
//! @inherit{QException::raise}
23-
void raise() const override;
22+
virtual void raise() const QTMVVM_EXCEPTION_OR;
2423
//! @inherit{QException::clone}
25-
QException *clone() const override;
24+
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
2625

2726
protected:
2827
//! @private

src/mvvmcore/mvvmcore.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ HEADERS += \
2525
isettingsaccessor.h \
2626
qsettingsaccessor.h \
2727
settingsentry.h \
28-
settingsconfigloader_p.h
28+
settingsconfigloader_p.h \
29+
exception.h
2930

3031
SOURCES += \
3132
viewmodel.cpp \

src/mvvmcore/serviceregistry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void ServiceExistsException::raise() const
335335
throw (*this);
336336
}
337337

338-
QException *ServiceExistsException::clone() const
338+
QTMVVM_EXCEPTION_BASE *ServiceExistsException::clone() const
339339
{
340340
return new ServiceExistsException(this);
341341
}
@@ -360,7 +360,7 @@ void ServiceConstructionException::raise() const
360360
throw (*this);
361361
}
362362

363-
QException *ServiceConstructionException::clone() const
363+
QTMVVM_EXCEPTION_BASE *ServiceConstructionException::clone() const
364364
{
365365
return new ServiceConstructionException(this);
366366
}
@@ -380,7 +380,7 @@ void ServiceDependencyException::raise() const
380380
throw (*this);
381381
}
382382

383-
QException *ServiceDependencyException::clone() const
383+
QTMVVM_EXCEPTION_BASE *ServiceDependencyException::clone() const
384384
{
385385
return new ServiceDependencyException(this);
386386
}

src/mvvmcore/serviceregistry.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
#include <QtCore/qscopedpointer.h>
77
#include <QtCore/qvariant.h>
8-
#include <QtCore/qexception.h>
98

109
#include "QtMvvmCore/qtmvvmcore_global.h"
1110
#include "QtMvvmCore/injection.h"
11+
#include "QtMvvmCore/exception.h"
1212

1313
namespace QtMvvm {
1414

@@ -108,7 +108,7 @@ class Q_MVVMCORE_EXPORT ServiceRegistry //MAJOR make a QObject for invokable met
108108
};
109109

110110
//! Is thrown if a service is beeing registered that is already registered
111-
class Q_MVVMCORE_EXPORT ServiceExistsException : public QException
111+
class Q_MVVMCORE_EXPORT ServiceExistsException : public QTMVVM_EXCEPTION_BASE
112112
{
113113
public:
114114
//! @private
@@ -118,9 +118,9 @@ class Q_MVVMCORE_EXPORT ServiceExistsException : public QException
118118
const char *what() const noexcept override;
119119

120120
//! @inherit{QException::raise}
121-
void raise() const override;
121+
virtual void raise() const QTMVVM_EXCEPTION_OR;
122122
//! @inherit{QException::clone}
123-
QException *clone() const override;
123+
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
124124

125125
protected:
126126
//! @private
@@ -131,7 +131,7 @@ class Q_MVVMCORE_EXPORT ServiceExistsException : public QException
131131
};
132132

133133
//! Is thrown in case the construction of a service has failed
134-
class Q_MVVMCORE_EXPORT ServiceConstructionException : public QException
134+
class Q_MVVMCORE_EXPORT ServiceConstructionException : public QTMVVM_EXCEPTION_BASE
135135
{
136136
public:
137137
//! @private
@@ -141,9 +141,9 @@ class Q_MVVMCORE_EXPORT ServiceConstructionException : public QException
141141
const char *what() const noexcept override;
142142

143143
//! @inherit{QException::raise}
144-
void raise() const override;
144+
virtual void raise() const QTMVVM_EXCEPTION_OR;
145145
//! @inherit{QException::clone}
146-
QException *clone() const override;
146+
virtual QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
147147

148148
protected:
149149
//! @private
@@ -161,7 +161,7 @@ class Q_MVVMCORE_EXPORT ServiceDependencyException : public ServiceConstructionE
161161
ServiceDependencyException(const QByteArray &iid);
162162

163163
void raise() const override;
164-
QException *clone() const override;
164+
QTMVVM_EXCEPTION_BASE *clone() const override;
165165

166166
protected:
167167
//! @private

src/mvvmcore/settingsconfigloader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void SettingsConfigException::raise() const
226226
throw *this;
227227
}
228228

229-
QException *SettingsConfigException::clone() const
229+
QTMVVM_EXCEPTION_BASE *SettingsConfigException::clone() const
230230
{
231231
return new SettingsConfigException{_what};
232232
}

src/mvvmcore/settingsconfigloader_p.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "qtmvvmcore_global.h"
88
#include "settingssetup.h"
9+
#include "exception.h"
910

1011
#include <settingsconfigimpl_p.h>
1112

@@ -57,8 +58,8 @@ class Q_MVVMCORE_EXPORT SettingsConfigException : public SettingsLoaderException
5758

5859
const char *what() const noexcept override;
5960

60-
void raise() const override;
61-
QException *clone() const override;
61+
void raise() const QTMVVM_EXCEPTION_OR;
62+
QTMVVM_EXCEPTION_BASE *clone() const QTMVVM_EXCEPTION_OR;
6263

6364
private:
6465
const QByteArray _what;

src/mvvmcore/settingssetup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <QtCore/qurl.h>
77
#include <QtCore/qobject.h>
88
#include <QtCore/qfileselector.h>
9-
#include <QtCore/qexception.h>
109

1110
#include "QtMvvmCore/qtmvvmcore_global.h"
11+
#include "QtMvvmCore/exception.h"
1212

1313
namespace QtMvvm {
1414

@@ -109,7 +109,7 @@ struct Setup
109109
}
110110

111111
//! An exception throw in case loading a settings setup went wrong
112-
class SettingsLoaderException : public QException {};
112+
class SettingsLoaderException : public QTMVVM_EXCEPTION_BASE {};
113113

114114
//! An interface for a generic settings setup loader
115115
class ISettingsSetupLoader

src/mvvmdatasynccore/datasyncsettingsaccessor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "datasyncsettingsaccessor.h"
22
#include "datasyncsettingsaccessor_p.h"
33
#include <QtCore/QRegularExpression>
4+
#include <QtMvvmCore/exception.h>
45

56
#undef logDebug
67
#undef logInfo
@@ -40,7 +41,7 @@ bool DataSyncSettingsAccessor::contains(const QString &key) const
4041
{
4142
try {
4243
return d->store->keys().contains(key);
43-
} catch(QException &e) {
44+
} catch (QTMVVM_EXCEPTION_BASE &e) {
4445
logCritical() << "Failed to check if entry" << key << "exists with error:"
4546
<< e.what();
4647
return false;
@@ -54,7 +55,7 @@ QVariant DataSyncSettingsAccessor::load(const QString &key, const QVariant &defa
5455
} catch (QtDataSync::NoDataException &e) {
5556
Q_UNUSED(e)
5657
return defaultValue;
57-
} catch (QException &e) {
58+
} catch (QTMVVM_EXCEPTION_BASE &e) {
5859
logCritical() << "Failed to load entry" << key << "from datasync settings with error:"
5960
<< e.what();
6061
return defaultValue;
@@ -65,7 +66,7 @@ void DataSyncSettingsAccessor::save(const QString &key, const QVariant &value)
6566
{
6667
try {
6768
d->store->save({key, value});
68-
} catch (QException &e) {
69+
} catch (QTMVVM_EXCEPTION_BASE &e) {
6970
logCritical() << "Failed to save entry" << key << "to datasync settings with error:"
7071
<< e.what();
7172
}
@@ -81,7 +82,7 @@ void DataSyncSettingsAccessor::remove(const QString &key)
8182
for(const auto &rmKey : rmKeys)
8283
d->store->remove(rmKey);
8384
d->store->remove(key);
84-
} catch (QException &e) {
85+
} catch (QTMVVM_EXCEPTION_BASE &e) {
8586
logCritical() << "Failed to remove entry" << key << "from datasync settings with error:"
8687
<< e.what();
8788
}

src/mvvmquick/quickpresenter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77
#include <QtCore/QDirIterator>
88
#include <QtCore/QMetaMethod>
99

10+
#include <QtMvvmCore/exception.h>
11+
1012
#include <QtQml/qqml.h>
1113

1214
#include <QtMvvmCore/private/qtmvvm_logging_p.h>
1315

1416
#include <qurlvalidator.h>
15-
namespace {
1617

17-
void qtMvvmQuickInit()
18+
static void qtMvvmQuickInit()
1819
{
1920
qmlRegisterType<QUrlValidator>("de.skycoder42.QtMvvm.Quick.Private", 1, 0, "UrlValidator");
2021
QtMvvm::ServiceRegistry::instance()->registerObject<QtMvvm::InputViewFactory>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
2122
QtMvvm::ServiceRegistry::instance()->registerInterface<QtMvvm::IPresenter, QtMvvm::QuickPresenter>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
2223
}
2324

24-
void initResources()
25+
static void initResources()
2526
{
2627
#ifdef QT_STATIC
2728
qtMvvmQuickInit();
2829
Q_INIT_RESOURCE(qtmvvmquick_module);
2930
#endif
3031
}
3132

32-
}
3333
Q_COREAPP_STARTUP_FUNCTION(qtMvvmQuickInit)
3434

3535
using namespace QtMvvm;
@@ -223,7 +223,7 @@ QuickPresenter *QuickPresenterPrivate::currentPresenter()
223223
"Cannot register views if the current presenter does not extend QtMvvm::QuickPresenter");
224224
#endif
225225
return static_cast<QuickPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
226-
} catch(QException &e) {
226+
} catch (QTMVVM_EXCEPTION_BASE &e) {
227227
qFatal("%s", e.what());
228228
}
229229
}

src/mvvmwidgets/widgetspresenter.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,26 @@
2222
#include <QtWidgets/QColorDialog>
2323

2424
#include <QtMvvmCore/CoreApp>
25+
#include <QtMvvmCore/exception.h>
2526
#include <QtMvvmCore/private/qtmvvm_logging_p.h>
2627

2728
#include <dialogmaster.h>
2829
#include <qurlvalidator.h>
2930

30-
namespace {
31-
32-
void qtMvvmWidgetsInit()
31+
static void qtMvvmWidgetsInit()
3332
{
3433
QtMvvm::ServiceRegistry::instance()->registerObject<QtMvvm::InputWidgetFactory>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
3534
QtMvvm::ServiceRegistry::instance()->registerInterface<QtMvvm::IPresenter, QtMvvm::WidgetsPresenter>(QtMvvm::ServiceRegistry::DestroyOnAppDestroy, true);
3635
}
3736

38-
void initResources()
37+
static void initResources()
3938
{
4039
#ifdef QT_STATIC
4140
qtMvvmWidgetsInit();
42-
Q_INIT_RESOURCE(qtmvvmsettingswidgets_module);
41+
Q_INIT_RESOURCE(qtmvvmwidgets_module);
4342
#endif
4443
}
4544

46-
}
4745
Q_COREAPP_STARTUP_FUNCTION(qtMvvmWidgetsInit)
4846

4947
using namespace QtMvvm;
@@ -508,7 +506,7 @@ WidgetsPresenter *WidgetsPresenterPrivate::currentPresenter()
508506
"Cannot register widgets if the current presenter does not extend QtMvvm::WidgetsPresenter");
509507
#endif
510508
return static_cast<WidgetsPresenter*>(ServiceRegistry::instance()->service<IPresenter>());
511-
} catch(QException &e) {
509+
} catch (QTMVVM_EXCEPTION_BASE &e) {
512510
qFatal("%s", e.what());
513511
}
514512
}

0 commit comments

Comments
 (0)