[PATCH] MarbleDebug: don't use a class extending QIODevice as a null device

Lubomir I. Ivanov neolit123 at gmail.com
Mon Apr 17 14:53:12 PDT 2017


On 18 April 2017 at 00:47, Thiago Macieira <thiago at macieira.org> wrote:
> On segunda-feira, 17 de abril de 2017 14:41:13 PDT Lubomir I. Ivanov wrote:
>> On 18 April 2017 at 00:18, Thiago Macieira <thiago at macieira.org> wrote:
>> > On segunda-feira, 17 de abril de 2017 14:10:28 PDT Lubomir I. Ivanov
> wrote:
>> >> i guess we could just do a:
>> >> void MarbleDebug::setEnabled(bool enabled)
>> >> {
>> >>
>> >>     Marble::loggingCategory.setEnabled(enabled);
>> >>     MarbleDebug::m_enabled = enabled;
>> >>
>> >> }
>> >
>> > I'd go a little further and drop the m_enabled variable completely. You
>> > don't need it, let the bit in the QLoggingCategory variable keep the
>> > state.
>> >
>> > You'd have:
>> >
>> > namespace MarbleDebug {
>> > Q_LOGGING_CATEGORY(category, "marble", QtWarningMsg)
>> >
>> > void setEnabled(bool enabled)
>> > {
>> >
>> >     category.setEnabled(QtDebugMsg, enabled);
>> >
>> > }
>> >
>> > bool isEnabled()                // do you even need this function?
>> > {
>> >
>> >         return category.isDebugEnabled();
>> >
>> > }
>> > } //namespace MarbleDebug
>> >
>> > This changes to the MarbleDebug namespace too.
>>
>> thanks, i think i understand.
>>
>> here are the updated Marble files and a patch diff for review.
>> i can't build Marble to test these changes ATM though.
>
> Looks good, so long as "Marble::category" isn't too generic a name.
>

ok, i've renamed it to Marable::loggingCategory.

Stefan, could you please try building and running the attached patch?
you can toggle the debugging with MarbleDebug::setEnabled(true/false)
e.g. from the Subsurface source code.

lubomir
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MarbleDebug.h
Type: text/x-chdr
Size: 1015 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170418/d3968187/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MarbleDebug.cpp
Type: text/x-c++src
Size: 615 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170418/d3968187/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-MarbleDebug-use-a-custom-QLoggingCategory.patch
Type: text/x-patch
Size: 2258 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20170418/d3968187/attachment.bin>


More information about the subsurface mailing list