~mterry/qtmir/report-osk-max-height

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/application.cpp

  • Committer: Daniel d'Andrada
  • Date: 2016-03-24 14:28:01 UTC
  • mto: (452.1.30 inline-gles-surface)
  • mto: This revision was merged to the branch mainline in revision 472.
  • Revision ID: daniel.dandrada@canonical.com-20160324142801-yghftb9xzyggnuji
Application: improve debug logging

Minimize boilerplate in logging code, as well as standardise its format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2013-2015 Canonical, Ltd.
 
2
 * Copyright (C) 2013-2016 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it under
5
5
 * the terms of the GNU Lesser General Public License version 3, as published by
34
34
 
35
35
namespace ms = mir::scene;
36
36
 
 
37
#define DEBUG_MSG qCDebug(QTMIR_APPLICATIONS).nospace() << "Application[" << appId() <<"]::" << __func__
 
38
 
37
39
namespace qtmir
38
40
{
39
41
 
56
58
    , m_closeTimer(nullptr)
57
59
    , m_exemptFromLifecycle(false)
58
60
{
59
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::Application - appId=" << desktopFileReader->appId();
 
61
    DEBUG_MSG << "()";
60
62
 
61
63
    // Because m_state is InternalState::Starting
62
64
    acquireWakelock();
73
75
 
74
76
Application::~Application()
75
77
{
76
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::~Application";
 
78
    DEBUG_MSG << "()";
77
79
 
78
80
    // (ricmm) -- To be on the safe side, better wipe the application QML compile cache if it crashes on startup
79
81
    if (m_processState == Application::ProcessUnknown) {
312
314
        return;
313
315
    }
314
316
 
315
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::setRequestedState - appId=" << appId()
316
 
                                << "requestedState=" << applicationStateToStr(value);
 
317
    DEBUG_MSG << "(requestedState=" << applicationStateToStr(value) << ")";
 
318
 
317
319
    m_requestedState = value;
318
320
    Q_EMIT requestedStateChanged(m_requestedState);
319
321
 
409
411
 
410
412
void Application::close()
411
413
{
412
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::close - appId=" << appId();
 
414
    DEBUG_MSG << "()";
413
415
 
414
416
    switch (m_state) {
415
417
    case InternalState::Starting:
460
462
 
461
463
void Application::setSession(SessionInterface *newSession)
462
464
{
463
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::setSession - appId=" << appId() << "session=" << newSession;
 
465
    DEBUG_MSG << "(session=" << newSession << ")";
464
466
 
465
467
    if (newSession == m_session)
466
468
        return;
511
513
 
512
514
void Application::setStage(Application::Stage stage)
513
515
{
514
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::setStage - appId=" << appId() << "stage=" << stage;
515
 
 
516
516
    if (m_stage != stage) {
517
517
        if ((stage | m_supportedStages) == 0) {
518
518
            return;
519
519
        }
 
520
        DEBUG_MSG << "(stage=" << stage << ")";
520
521
 
521
522
        m_stage = stage;
522
523
        Q_EMIT stageChanged(stage);
529
530
        return;
530
531
    }
531
532
 
532
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::setInternalState - appId=" << appId()
533
 
        << "state=" << internalStateToStr(state);
 
533
    DEBUG_MSG << "(state=" << internalStateToStr(state) << ")";
534
534
 
535
535
    auto oldPublicState = this->state();
536
536
    m_state = state;
570
570
 
571
571
void Application::setFocused(bool focused)
572
572
{
573
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::setFocused - appId=" << appId() << "focused=" << focused;
 
573
    DEBUG_MSG << "(focused=" << focused << ")";
574
574
 
575
575
    if (m_focused != focused) {
576
576
        m_focused = focused;
638
638
 
639
639
void Application::suspend()
640
640
{
641
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::suspend - appId=" << appId();
 
641
    DEBUG_MSG << "()";
642
642
 
643
643
    Q_ASSERT(m_state == InternalState::Running);
644
644
    Q_ASSERT(m_session != nullptr);
656
656
 
657
657
void Application::resume()
658
658
{
659
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::resume - appId=" << appId();
 
659
    DEBUG_MSG << "()";
660
660
 
661
661
    if (m_state == InternalState::Suspended || m_state == InternalState::SuspendingWaitProcess) {
662
662
        setInternalState(InternalState::Running);
675
675
 
676
676
void Application::respawn()
677
677
{
678
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::respawn - appId=" << appId();
 
678
    DEBUG_MSG << "()";
679
679
 
680
680
    setInternalState(InternalState::Starting);
681
681
 
684
684
 
685
685
void Application::stop()
686
686
{
687
 
    qCDebug(QTMIR_APPLICATIONS) << "Application::stop - appId=" << appId();
 
687
    DEBUG_MSG << "()";
688
688
 
689
689
    Q_EMIT stopProcessRequested();
690
690
}
806
806
 
807
807
void Application::setInitialSurfaceSize(const QSize &size)
808
808
{
809
 
    qCDebug(QTMIR_APPLICATIONS).nospace() << "Application::setInitialSurfaceSize - appId=" << appId()
810
 
        << " size=" << size;
 
809
    DEBUG_MSG << "(size=" << size << ")";
811
810
 
812
811
    if (size != m_initialSurfaceSize) {
813
812
        m_initialSurfaceSize = size;