author | zecke <zecke> | 2004-09-21 16:01:21 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-21 16:01:21 (UTC) |
commit | 56f3bcad1a0abd199a458a62c8bde0ebdff035d5 (patch) (unidiff) | |
tree | 9f81f2d9ae430f98079149f53dd86eddd09ceec8 | |
parent | 97e20b7cc746d5e2822385fc815739853a9c6e2f (diff) | |
download | opie-56f3bcad1a0abd199a458a62c8bde0ebdff035d5.zip opie-56f3bcad1a0abd199a458a62c8bde0ebdff035d5.tar.gz opie-56f3bcad1a0abd199a458a62c8bde0ebdff035d5.tar.bz2 |
Only disconnect from sender if sender() is valid
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index ec861ee..b5ae4e5 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -719,129 +719,131 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
719 | 719 | ||
720 | /** | 720 | /** |
721 | * @internal | 721 | * @internal |
722 | */ | 722 | */ |
723 | void ODevice::virtual_hook(int, void* ){ | 723 | void ODevice::virtual_hook(int, void* ){ |
724 | 724 | ||
725 | } | 725 | } |
726 | 726 | ||
727 | /** | 727 | /** |
728 | * \brief Send a QCOP Message before suspending | 728 | * \brief Send a QCOP Message before suspending |
729 | * | 729 | * |
730 | * Sends a QCOP message to channel QPE/System | 730 | * Sends a QCOP message to channel QPE/System |
731 | * with the message "aboutToSuspend()" if this | 731 | * with the message "aboutToSuspend()" if this |
732 | * is the windowing server. | 732 | * is the windowing server. |
733 | * | 733 | * |
734 | * Call this in your custom \sa suspend() Method | 734 | * Call this in your custom \sa suspend() Method |
735 | * before going to suspend. | 735 | * before going to suspend. |
736 | * | 736 | * |
737 | */ | 737 | */ |
738 | void ODevice::sendSuspendmsg() | 738 | void ODevice::sendSuspendmsg() |
739 | { | 739 | { |
740 | if ( isQWS() ) | 740 | if ( isQWS() ) |
741 | return; | 741 | return; |
742 | 742 | ||
743 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); | 743 | QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); |
744 | } | 744 | } |
745 | 745 | ||
746 | /** | 746 | /** |
747 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters | 747 | * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters |
748 | * | 748 | * |
749 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard | 749 | * Prepend a QWSServer::KeyboardFilter to the List of Keyboard |
750 | * Filters. This function is the only way to prepend a KeyFilter. | 750 | * Filters. This function is the only way to prepend a KeyFilter. |
751 | * | 751 | * |
752 | * @param aFilter The KeyFilter to be prepended to the list of filters | 752 | * @param aFilter The KeyFilter to be prepended to the list of filters |
753 | * | 753 | * |
754 | * @see Opie::Core::OKeyFilter | 754 | * @see Opie::Core::OKeyFilter |
755 | * @see Opie::Core::OKeyFilter::inst() | 755 | * @see Opie::Core::OKeyFilter::inst() |
756 | */ | 756 | */ |
757 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 757 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) |
758 | { | 758 | { |
759 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); | 759 | Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); |
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list | 763 | * \brief Remove the QWSServer::KeyboardFilter in the param from the list |
764 | * | 764 | * |
765 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List | 765 | * Remove the QWSServer::KeyboardFilter \par aFilter from the List |
766 | * of Keyfilters. Call this when you delete the KeyFilter! | 766 | * of Keyfilters. Call this when you delete the KeyFilter! |
767 | * | 767 | * |
768 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter | 768 | * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter |
769 | * @see Opie::Core::ODevice::addPreHandler | 769 | * @see Opie::Core::ODevice::addPreHandler |
770 | */ | 770 | */ |
771 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 771 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) |
772 | { | 772 | { |
773 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); | 773 | Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); |
774 | } | 774 | } |
775 | 775 | ||
776 | 776 | ||
777 | /** | 777 | /** |
778 | * @internal | 778 | * @internal |
779 | * | 779 | * |
780 | * @see changeMixerForAlarm | 780 | * @see changeMixerForAlarm |
781 | */ | 781 | */ |
782 | void ODevice::playingStopped() { | 782 | void ODevice::playingStopped() { |
783 | const_cast<QObject*>(sender())->disconnect( this ); | 783 | if ( sender() ) |
784 | const_cast<QObject*>(sender())->disconnect( this ); | ||
785 | |||
784 | #ifndef QT_NO_SOUND | 786 | #ifndef QT_NO_SOUND |
785 | if ( d->m_sound >= 0 ) { | 787 | if ( d->m_sound >= 0 ) { |
786 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); | 788 | ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); |
787 | ::close ( d->m_sound ); | 789 | ::close ( d->m_sound ); |
788 | } | 790 | } |
789 | #endif | 791 | #endif |
790 | } | 792 | } |
791 | 793 | ||
792 | 794 | ||
793 | /** | 795 | /** |
794 | * \brief Change the Volume for the Alarm and set it back after playing is finished | 796 | * \brief Change the Volume for the Alarm and set it back after playing is finished |
795 | * | 797 | * |
796 | * If you play an Alarm Sound you might want to change the Mixer to | 798 | * If you play an Alarm Sound you might want to change the Mixer to |
797 | * full volume and ignore the user setting. After it \sa Sound::isFinished | 799 | * full volume and ignore the user setting. After it \sa Sound::isFinished |
798 | * you would turn the volume back to the user preference. | 800 | * you would turn the volume back to the user preference. |
799 | * The problem is that we used to enter the event loop while waiting | 801 | * The problem is that we used to enter the event loop while waiting |
800 | * for the sound to be finished triggering all kind of reentrance | 802 | * for the sound to be finished triggering all kind of reentrance |
801 | * problems what a library shouldn't introduce. | 803 | * problems what a library shouldn't introduce. |
802 | * Instead of manually waiting for the sound to be finished use | 804 | * Instead of manually waiting for the sound to be finished use |
803 | * this Method and it will automatically restore the Mixer to | 805 | * this Method and it will automatically restore the Mixer to |
804 | * the user configuration after the sound finished playing. | 806 | * the user configuration after the sound finished playing. |
805 | * | 807 | * |
806 | * Note: The onwership of \param snd is not transfered and playing | 808 | * Note: The onwership of \param snd is not transfered and playing |
807 | * is not started in this method. If 'snd' gets deleted before | 809 | * is not started in this method. If 'snd' gets deleted before |
808 | * playing is finished the volume doesn't get set back to | 810 | * playing is finished the volume doesn't get set back to |
809 | * the user preference! | 811 | * the user preference! |
810 | * | 812 | * |
811 | * \code | 813 | * \code |
812 | * static Sound snd("alarm"); | 814 | * static Sound snd("alarm"); |
813 | * if(!snd.isFinished()) | 815 | * if(!snd.isFinished()) |
814 | * return; | 816 | * return; |
815 | * | 817 | * |
816 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); | 818 | * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); |
817 | * snd.play() | 819 | * snd.play() |
818 | * \endcode | 820 | * \endcode |
819 | * | 821 | * |
820 | * | 822 | * |
821 | * | 823 | * |
822 | * @param mixer The mixer number/channel to use | 824 | * @param mixer The mixer number/channel to use |
823 | * @param file The file name. If you convert from QString use QFile::encodeName | 825 | * @param file The file name. If you convert from QString use QFile::encodeName |
824 | * @param snd The sound to wait for finishing | 826 | * @param snd The sound to wait for finishing |
825 | * | 827 | * |
826 | */ | 828 | */ |
827 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { | 829 | void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { |
828 | #ifndef QT_NO_SOUND | 830 | #ifndef QT_NO_SOUND |
829 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { | 831 | if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { |
830 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { | 832 | if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { |
831 | Config cfg ( "qpe" ); | 833 | Config cfg ( "qpe" ); |
832 | cfg. setGroup ( "Volume" ); | 834 | cfg. setGroup ( "Volume" ); |
833 | 835 | ||
834 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 836 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
835 | if ( volalarm < 0 ) | 837 | if ( volalarm < 0 ) |
836 | volalarm = 0; | 838 | volalarm = 0; |
837 | else if ( volalarm > 100 ) | 839 | else if ( volalarm > 100 ) |
838 | volalarm = 100; | 840 | volalarm = 100; |
839 | volalarm |= ( volalarm << 8 ); | 841 | volalarm |= ( volalarm << 8 ); |
840 | 842 | ||
841 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) | 843 | if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) |
842 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); | 844 | register_qpe_sound_finished(snd, this, SLOT(playingStopped())); |
843 | } | 845 | } |
844 | d->m_mixer = mixer; | 846 | d->m_mixer = mixer; |
845 | } | 847 | } |
846 | #endif | 848 | #endif |
847 | } | 849 | } |