Ticket #4116: 4116-fixes-v1.patch
File 4116-fixes-v1.patch, 8.7 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/osdtypes.cpp
658 658 659 659 OSDTypeText::OSDTypeText(const QString &name, TTFFont *font, 660 660 const QString &text, QRect displayrect, 661 float wmult, float hmult) 662 : OSDType(name) 663 { 664 m_message = text; 665 m_default_msg = text; 666 m_font = font; 661 float wmult, float hmult) : 662 OSDType(name), 663 m_lock(true), 664 m_displaysize(displayrect), 665 m_screensize(displayrect), 666 m_unbiasedsize(unbias(m_screensize, wmult, hmult)), 667 m_message(QDeepCopy<QString>(text)), 668 m_default_msg(QDeepCopy<QString>(text)), 667 669 668 m_altfont = NULL; 669 670 m_displaysize = displayrect; 671 m_screensize = displayrect; 672 m_multiline = false; 673 m_centered = false; 674 m_right = false; 675 m_usingalt = false; 670 m_font(font), 671 m_altfont(NULL), 676 672 677 m_selected = false; 678 m_button = false; 679 m_entrynum = -1; 680 m_cursorpos = 0; 673 m_centered(false), 674 m_right(false), 681 675 682 m_scroller = false; 683 m_scrollx = m_scrolly = 0; 684 m_scrollinit = false; 676 m_multiline(false), 677 m_usingalt(false), 685 678 686 m_linespacing = 1.5; 679 m_selected(false), 680 m_button(false), 681 m_entrynum(-1), 682 m_cursorpos(0), 687 683 688 m_unbiasedsize = unbias(m_screensize, wmult, hmult); 684 m_scroller(false), 685 m_scrollx(0), 686 m_scrolly(0), 689 687 690 m_draw_info_str = ""; 691 m_draw_info_len = 0; 688 m_scrollinit(false), 689 690 m_linespacing(1.5f), 691 692 m_draw_info_str(""), 693 m_draw_info_len(0) 694 { 692 695 } 693 696 694 OSDTypeText::OSDTypeText(const OSDTypeText &other) 695 : OSDType(other.m_name) 697 OSDTypeText::OSDTypeText(const OSDTypeText &other) : 698 OSDType(other.m_name), 699 m_draw_info_str(""), 700 m_draw_info_len(0) 696 701 { 697 m_message = other.m_message; 698 m_default_msg = other.m_default_msg; 702 QMutexLocker locker(&other.m_lock); 703 704 m_displaysize = other.m_displaysize; 705 m_screensize = other.m_screensize; 706 m_unbiasedsize = other.m_unbiasedsize; 707 708 m_message = QDeepCopy<QString>(other.m_message); 709 m_default_msg = QDeepCopy<QString>(other.m_default_msg); 710 699 711 m_font = other.m_font; 700 701 712 m_altfont = other.m_altfont; 702 713 703 m_displaysize = other.m_displaysize;704 m_screensize = other.m_screensize;705 m_multiline = other.m_multiline;706 714 m_centered = other.m_centered; 707 715 m_right = other.m_right; 708 m_usingalt = other.m_usingalt; 709 710 m_selected = other.m_selected; 711 m_button = other.m_button; 712 m_entrynum = other.m_entrynum; 713 m_cursorpos = other.m_cursorpos; 714 716 717 m_multiline = other.m_multiline; 718 m_usingalt = other.m_usingalt; 719 720 m_selected = other.m_selected; 721 m_button = other.m_button; 722 m_entrynum = other.m_entrynum; 723 m_cursorpos = other.m_cursorpos; 724 715 725 m_scroller = other.m_scroller; 716 726 m_scrollx = other.m_scrollx; 717 727 m_scrolly = other.m_scrolly; 728 718 729 m_scrollinit = other.m_scrollinit; 719 730 720 731 m_linespacing = other.m_linespacing; 721 722 m_unbiasedsize = other.m_unbiasedsize;723 724 m_draw_info_str = "";725 m_draw_info_len = 0;726 732 } 727 733 728 734 OSDTypeText::~OSDTypeText() … … 731 737 732 738 void OSDTypeText::SetAltFont(TTFFont *font) 733 739 { 740 QMutexLocker locker(&m_lock); 734 741 m_altfont = font; 735 742 } 736 743 737 744 void OSDTypeText::SetText(const QString &text) 738 745 { 739 m_message = text; 746 QMutexLocker locker(&m_lock); 747 m_message = QDeepCopy<QString>(text); 740 748 m_cursorpos = text.length(); 741 749 m_scrollinit = false; 742 750 } 743 751 752 QString OSDTypeText::GetText(void) const 753 { 754 QMutexLocker locker(&m_lock); 755 return QDeepCopy<QString>(m_message); 756 } 757 744 758 void OSDTypeText::SetDefaultText(const QString &text) 745 759 { 746 m_message = text; 747 m_default_msg = text; 760 QMutexLocker locker(&m_lock); 761 m_message = QDeepCopy<QString>(text); 762 m_default_msg = QDeepCopy<QString>(text); 748 763 m_scrollinit = false; 749 764 } 765 766 QString OSDTypeText::GetDefaultText(void) const 767 { 768 QMutexLocker locker(&m_lock); 769 return QDeepCopy<QString>(m_default_msg); 770 } 750 771 772 void OSDTypeText::SetMultiLine(bool multi) 773 { 774 QMutexLocker locker(&m_lock); 775 m_multiline = multi; 776 } 777 778 void OSDTypeText::SetCentered(bool docenter) 779 { 780 QMutexLocker locker(&m_lock); 781 m_centered = docenter; 782 } 783 784 void OSDTypeText::SetRightJustified(bool right) 785 { 786 QMutexLocker locker(&m_lock); 787 m_right = right; 788 } 789 790 void OSDTypeText::SetScrolling(int x, int y) 791 { 792 QMutexLocker locker(&m_lock); 793 m_scroller = true; 794 m_scrollx = x; 795 m_scrolly = y; 796 } 797 798 void OSDTypeText::SetLineSpacing(float linespacing) 799 { 800 QMutexLocker locker(&m_lock); 801 m_linespacing = linespacing; 802 } 803 751 804 void OSDTypeText::Reinit(float wmult, float hmult) 752 805 { 806 QMutexLocker locker(&m_lock); 753 807 m_displaysize = m_screensize = bias(m_unbiasedsize, wmult, hmult); 754 808 } 755 809 756 810 void OSDTypeText::Draw(OSDSurface *surface, int fade, int maxfade, int xoff, 757 811 int yoff) 758 812 { 813 QMutexLocker locker(&m_lock); 814 815 // initialize regular expressions once, this is a very slow operation 816 static QMutex regexp_lock; 817 static QRegExp br("%BR%"); 818 static QRegExp nl("\n"); 819 759 820 int textlength = 0; 760 821 761 822 if (m_message == QString::null) … … 773 834 774 835 if (m_multiline) 775 836 { 776 QString tmp_msg = m_message; 777 tmp_msg.replace(QRegExp("%BR%"), "\n"); 778 tmp_msg.replace(QRegExp("\n")," \n "); 837 QString tmp_msg = QDeepCopy<QString>(m_message); 838 regexp_lock.lock(); 839 tmp_msg.replace(br, "\n"); 840 tmp_msg.replace(nl," \n "); 841 regexp_lock.unlock(); 779 842 780 843 QStringList wordlist = QStringList::split(" ", tmp_msg); 781 844 int length = 0; … … 902 965 const QString &text, int fade, int maxfade, 903 966 int xoff, int yoff, bool double_size) 904 967 { 968 QMutexLocker locker(&m_lock); 969 905 970 if (m_draw_info_str != text) 906 971 { 907 972 m_draw_info_str = QDeepCopy<QString>(text); … … 1015 1080 const QString &text, int fade, int maxfade, 1016 1081 int xoff, int yoff, bool doubl) 1017 1082 { 1083 QMutexLocker locker(&m_lock); 1084 1018 1085 if (m_centered || m_right) 1019 1086 { 1020 1087 int textlength = 0; … … 1067 1134 1068 1135 bool OSDTypeText::MoveCursor(int dir) 1069 1136 { 1137 QMutexLocker locker(&m_lock); 1138 1070 1139 if (!IsEntry() || IsButton()) 1071 1140 return false; 1072 1141 … … 1077 1146 1078 1147 bool OSDTypeText::Delete(int dir) 1079 1148 { 1149 QMutexLocker locker(&m_lock); 1150 1080 1151 if (!IsEntry() || IsButton()) 1081 1152 return false; 1082 1153 … … 1099 1170 1100 1171 void OSDTypeText::InsertCharacter(QChar ch) 1101 1172 { 1173 QMutexLocker locker(&m_lock); 1174 1102 1175 if (!IsEntry() || IsButton()) 1103 1176 return; 1104 1177 -
libs/libmythtv/osdtypes.h
202 202 void SetUseAlt(bool usealt) { m_usingalt = usealt; } 203 203 204 204 void SetText(const QString &text); 205 QString GetText( ) { return m_message; }205 QString GetText(void) const; 206 206 207 207 void SetDefaultText(const QString &text); 208 QString GetDefaultText( ) { return m_default_msg; }208 QString GetDefaultText(void) const; 209 209 210 void SetMultiLine(bool multi) { m_multiline = multi; }211 bool GetMultiLine( ){ return m_multiline; }210 void SetMultiLine(bool multi); 211 bool GetMultiLine(void) const { return m_multiline; } 212 212 213 void SetCentered(bool docenter) { m_centered = docenter; }214 bool GetCentered( ){ return m_centered; }213 void SetCentered(bool docenter); 214 bool GetCentered(void) const { return m_centered; } 215 215 216 void SetRightJustified(bool right) { m_right = right; }217 bool GetRightJustified( ){ return m_right; }216 void SetRightJustified(bool right); 217 bool GetRightJustified(void) const { return m_right; } 218 218 219 void SetScrolling(int x, int y) { m_scroller = true; m_scrollx = x; 220 m_scrolly = y; } 219 void SetScrolling(int x, int y); 221 220 222 void SetLineSpacing(float linespacing) { m_linespacing = linespacing; }223 float GetLineSpacing( ){ return m_linespacing; }221 void SetLineSpacing(float linespacing); 222 float GetLineSpacing(void) const { return m_linespacing; } 224 223 225 224 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff); 226 225 bool MoveCursor(int dir); … … 245 244 const QString &text, int fade, int maxfade, 246 245 int xoff, int yoff, bool double_size = false); 247 246 247 mutable QMutex m_lock; 248 248 249 QRect m_displaysize; 249 250 QRect m_screensize; 250 251 QRect m_unbiasedsize;